Demo entry 6358546

chapter1 code1

   

Submitted by anonymous on Apr 26, 2017 at 03:57
Language: SAS. Code size: 828 Bytes.

/*汇总计算汽车品牌下的数量,平均零售价,市场价格以及每英里油耗*/
PROC Tabulate data=Sashelp.Cars out=Work.Acura_ave_price_mpg;*输出结果到临时数据集;
  where lowcase(make) = "acura";*选择品牌讴歌Acura;
  var MSRP Invoice MPG_City MPG_Highway;
  table (MSRP="平均建议零售价(美元)" 
         Invoice="平均市场价格(美元)" 
         MPG_City="城市每加仑行驶距离(英里)" 
         MPG_Highway="高速公路每加仑行驶距离(英里)") * 
         (Mean=""*f=9.1) 
         N="车型数量";
run;

/*输出文字总结到结果页面*/
Data _null_;
  file print;*更改put语句的输出目标到结果页面;
  format MSRP_Mean Invoice_Mean MPG_City_Mean MPG_Highway_Mean 9.1;*保留一位小数;
  set Work.Acura_ave_price_mpg;
  put "品牌Acura共有车型" N +(-1) 
      "款,平均建议零售价是" MSRP_Mean +(-1) "美元," @;
  put "平均市场价格是" Invoice_Mean +(-1)
      "美元,城市中的每加仑行驶距离是" MPG_City_Mean +(-1) @;
  put "英里,而在高速公路上每加仑行驶距离是" MPG_Highway_Mean +(-1) "英里。";
  *每个变量解析之后,向后移动一列光标,以消除变量后的空格;
run;

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).