PROC SQL中逻辑判别和描述性统计函数怎么用

这篇文章主要介绍了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;

感谢你能够认真阅读完这篇文章,希望小编分享的“PROC SQL中逻辑判别和描述性统计函数怎么用”这篇文章对大家有帮助,同时也希望大家多多支持蜗牛博客,关注蜗牛博客行业资讯频道,更多相关知识等着你来学习!

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:niceseo99@gmail.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

评论

有免费节点资源,我们会通知你!加入纸飞机订阅群

×
天气预报查看日历分享网页手机扫码留言评论电报频道链接