PROC SQL中的逻辑判别和描述性统计函数

1.逻辑表达:>,<,!=,....

*data step;
data class_flags;
   set sashelp.class;
   tall = (height > 60);
   male = (sex = 'M');
   female = (sex = 'F');
run;
*proc sql;
proc sql;
   select name, 
          (height > 60) as tall, 
          (sex = 'M') as male, 
          (sex = 'F') as female
   from sashelp.class;
quit;

2.描述性统计函数sum(),mean(),....

proc sql;
   select sex, 
          max(height) as max_ht, 
          mean(weight) as mean_wt
   from sashelp.class
   group by sex;
quit;

proc sql;
   select age, 
          max(height*height/weight) as max_body_mass_index
   from sashelp.class
   group by age;
quit;

3.联合使用

proc sql;
   select max(height > 60) as any_tall, 
          mean(weight > 100) as pct_heavy,
          sum(gender = 'F') as num_female
   from sashelp.class;
quit;

 

proc sql;
   select sex,
          max(height > 60) as any_tall, mean(weight > 100) as pct_heavy
   from sashelp.class
   group by sex;
quit;

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值