为了账号安全,请及时绑定邮箱和手机立即绑定

SAS Proc Freq

标签:
大数据

回首页
新建文集
新建文章
在下方新建文章
已保存
SAS Proc Freq
已发布
SAS Day 37

In previous days, we discussed generating Statistical Summary using Proc Means and Proc Univariate for Continuous Variables(Age, BMI, Height, Weight).

Now, there is a question, what procedure should we apply to generate Categorical Variables (Sex, Race, Country)?

Today we will show how to use Proc Freq to summarize the Categorical Variables.

[caption id=“attachment_2305” align=“alignnone” width=“750”]

MichaelGaida / Pixabay[/caption]

Proc Freq:

Sample dataset:

Subjid ID: 1-96
Sex: Female, Male
TRT: Treatment Group 1,2

image

Sample Output:

image

Sample SAS Code:

%macro freq(in= , var= , out1= , out2= , sorter= ); 

proc freq data=&in noprint ; 
tables trt*&var /out=&out1 nopercent; 
run; 

proc sort data=&out1; 
by &var; 
run; 

proc transpose data=&out1 out=&out2(rename=(&var=label)) prefix=c; 
var count; 
by &var; 
id trt; 
run; 

data &out2; 
length label $100.; 
set &out2; 
sorter=&sorter; 
if sorter2=. then sorter2=2; 
drop _name_ _label_;
run; 
%mend freq; 

%freq(in=adsl, var=sex, out1=s1, out2=s, sorter=2);

Warm Attention: This Macro Freq I generated based on my interest, maybe you can add and subtract to tailor your needs.

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消