使用PROC REPORT的SAS数据表

时间:2018-11-08 22:43:20

标签: stored-procedures sas tabular

我是使用SAS的初学者,我的任务是创建一个如下表:

                      Group A                           Group B          All
               A   B   C   D   E   F            G  H  I  J  K  L  M 
Age 
   n           
   mean(sd)
   median
   min-max 
Gender
   n 
   fl
   ml
Race
   n 
   white 
   asian
   hispanic 
   black 

表中的空白仅是基于条件的计算。我考虑做的是以下操作,但是看起来不正确,并且有错误。无论如何,是否可以解决此问题,或者使用proc freq / proc制表,如果更简单:

Libname test '/home/user/username'; 
DATA test; 
SET test.test(keep = GROUP LETTER AGE GENDER RACE); 
RUN; 
PROC SORT DATA = test; 
    BY GROUP LETTER AGE GENDER RACE; 
PROC MEANS DATA = test; 
    CLASS GROUP LETTER;  
    VAR AGE GENDER RACE; 
RUN; 
PROC PRINT DATA = test; 
    TITLE 'Demographics';
RUN;
PROC PRINT DATA=test;
RUN;  
PROC TRANSPOSE DATA = test.test;
            OUT = test.test;
            BY GROUP LETTER;
            VAR GROUP LETTER;
RUN; 
PROC REPORT DATA = asl.asl;
    COLUMN GROUP LETTER AGE GENDER RACE; 
    DEFINE GROUP /DISPLAY 'Group'; 
    DEFINE LETTER /DISPLAY 'Letter';
    DEFINE AGE /DISPLAY 'Age'; 
    DEFINE GENDER /DISPLAY 'Gender';
    DEFINE RACE /DISPLAY 'Race';
RUN; 

0 个答案:

没有答案