亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

SAS Proc Univariate

標簽:
機器學習

SAS Day 36

In SAS Day 27, we showed using Proc Means to generate the statistical summaries for Continuous Variable such as (Age, BMI, Height, Weight). As an old idiom stated, “All Roads lead to Rome”.  Today we will introduce Proc Univariate to create the Summary Statistics.

[caption id=“attachment_2299” align=“alignnone” width=“750”]image

The_Double_A / Pixabay[/caption]

Task: Proc Univariate Sample for Statistical Summaries

Sample Dataset :

n: patient ID number

trt: treatment group

AGE: patient age

image

Output:

image

Sample Code:

macro uni(in=, var=, output=, sorter=); 

proc univariate data=&in noprint; 
  var &var; 
  class trt; 
  output out=x n=nn mean=meann  std=stdn median=mediann min=minn max=maxn q1=q1n q3=q3n ; 
run; 

data x; 
  set x; 
    length n $3\. mean $20\. median $25\. sd $8.3 q13$13\. mm $13\. ; 
    mean=put(meann,8.1); 
    median=put(mediann,3.) || "(" || put(minn,3.)||'-'||put(maxn,3.) ||")" ; 
    sd=put(stdn,8.2) ; 
    q13=put(q1n,6.1)||'-'||put(q3n,6.1); 
    mm=put(minn,6.1)||'-'||put(maxn,6.1); 
  n=put(nn,3.); 
  label n='   N' 
        mean='   Mean' 
        median='   Median'  
        sd="   Standard deviation" 
        q13="   25th-75th percentile" 
        mm='   Min-Max'; 
  keep n mean median mm q13 sd trt; 
run; 

proc transpose data=x out=&output(drop=_NAME_) prefix=col; 
  var n mean  median mm sd q13; 
  id trt; 
run; 

data &output; 
  length label $100\. col1 $40\. col2 $40\.  ; 
  set &output; 
  label=_LABEL_; 
  if label='   N' then sorter2=1; 
  else if label='   Mean' then sorter2=2; 
  else if label='   Median(range)' then sorter2=3; 
  else if label="   Standard deviation" then sorter2=4; 
  else if label="   25th-75th percentile" then sorter2=5; 
  else if label='   Min-Max' then sorter2=6; 
  sorter= &sorter; 
  keep sorter sorter2 label col:; 
proc sort; by sorter2; 
run; 
%mend uni; 

%uni(in=adsl, var=age, sorter= 1, output=a1);

Note: Special thanks to Alex Tian (Lipu), the sample code was originated by him. I modified the label and order along the time.
so maybe you could do your Mix and Match with this sample Proc Univariate code.

點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消