- data little.energy_tabulate;
- length State $2;
- input Region Division state $ Type Expenditures;
- datalines;
- 1 1 ME 1 708
- 1 1 ME 2 379
- 1 3 ME 1 348
- 1 2 ME 2 559
- 4 3 HI 1 273
- 3 2 HI 2 298
- 4 1 HI 1 373
- 4 1 HI 2 458
- 3 3 HI 2 298
- 4 4 HI 1 373
- 4 1 HI 2 458
- 1 2 ME 2 559
- 2 3 HI 1 273
- 3 2 HI 2 298
- 4 3 HI 1 373
- 2 3 HI 2 458
- 4 4 HI 1 273
- 4 4 HI 2 298
- ;
- run;
- ;proc format;
- value regfmt 1='Northeast'
- 2='South'
- 3='Midwest'
- 4='West';
- value divfmt 1='New England'
- 2='Middle Atlantic'
- 3='Mountain'
- 4='Pacific';
- value usetype 1='Residential Customers'
- 2='Business Customers';
- run;
- /*【tabulate1】——不限制输出*/
- proc tabulate data=little.energy_tabulate format=dollar12.;
- class region division type;/* 区域分割变量*/
- var expenditures; /* 分析变量*/
- table region*division,
- type*expenditures / rts=25; /* 一行容纳的字母数*/
- format region regfmt. division divfmt. type usetype.;
- title 'Energy Expenditures for Each Region';
- title2 '(millions of dollars)';
- run;
- data little.class;/*【选择性输出,只输出部分属性与属性的组合】
- ,数据透视表无法直接做到*/
- input region division type;
- datalines;
- 1 1 1
- 1 1 2
- 4 4 1
- 4 4 2
- ;
- run;
- /*【tabulate2】-属性组合输出*/
- /*PS:对比【tabulate1】和【tabulate2】的不同之处*/
- proc tabulate data=little.energy_tabulate format=dollar12.
- classdata=little.class exclusive;
- class region division type;
- var expenditures; /* 分析变量*/
- table region*division,
- type*expenditures / rts=25; /* 一行容纳的字母数*/
- format region regfmt. division divfmt. type usetype.;
- title 'Energy Expenditures for Each Region';
- title2 '(millions of dollars)';
- run;