report  输出list  

proc report data=flights.europe nowd; *也有wd;
run;

proc report data=flights.europe nowd;
  column flight orig dest mail freight revenue; *选择变量;
run;

proc report data=flights.europe nowd;
  column flight orig dest mail freight revenue;
  where dest in ('LON','PAR');        *选择观察单位
run; 

proc report data=flights.europe nowd;
  where dest in ('LON','PAR');
  column flight orig dest mail freight revenue;
  define revenue/format=dollar15.2;    *属性有三种,format=  ;   

  define flight/width=6;             *属性2,width表示该变量的宽度,默认的:字符类宽度的基于变量值最长得,数字型的为9,变量名超过width会自动换行;

  define orig / width=4 spacing=5;   *属性3,列与列之间的距离,默认为2;

  define orig / 'Flight Origin';     *修改变量名;

run;

proc report data=flights.europe nowd;

  column flight orig dest mail freight revenue;

  define orig / 'Flight/Origin';                   *变量名换行,默认用正斜杠;

run;
proc report data=flights.europe nowd split='&';         *把变量名拆为行,可以为任意符号,需要用split指定;
  column flight orig dest mail freight revenue;
  define orig / 'Flight&Origin';  
  define dest / center; *变量名与变量值的相对位置,有center,left,right,默认character靠左,number靠右;
run;

proc report data=flights.europe nowd headline headskip;    *把变量名和变量值分开, line加下划线,skip加空白距离;
  column flight orig dest mail freight revenue;
  define dest / center;
  define flight / order *用法: 显示该列,第一次出现的不同的值//隐去多次出现的重复值
                                    默认ascend,可以order descending;


run;

report  输出 summary

proc report data=flights.europe nowd headline headskip;
  where dest in ('LON','PAR');
  column flight orig dest mail freight revenue;
  define revenue / mean format=dollar15.2;                     *默认计算为该变量sum,可以修改
  define flight / group 'Flight/Number' width=6 center;         * group summary(相同值得观测单位被折叠collapsed)时,所有的变量必须 define group analysis across computed;
  define orig / width=6 spacing=5 'Flight/Origin' center;        *必须refine group 其他的character变量   若不,group=order;
  define dest / width=11 spacing=5 'Flight/Destination' center;
run;


proc report data=flights.europe nowd headline headskip;

    where dest in ('LON','PAR');
    column flight dest mail freight revenue;
    define revenue / format=dollar15.2;
    define flight / across 'Flight/Number' width=6 center;
    define dest / across width=11 spacing=5          *across 类似group,对num变量和group一样,对character像 R table(频数)
    'Flight/Destination' center;
  run;

proc report data=clinic.admit nowd headskip;
  column sex height weight distant;        *用法:创建新变量,需要在column中加入这个变量;
  define sex/group;
  define distant/computed 'd';               
  compute distant ;
  distant= height.sum-weight.sum;         * variablename。statistic
  endcomp;
run;

02-13 07:57