2

我有一个proc列表代码如下:

  proc tabulate data=want;
class TERM CAMPUS GENDER ;
  var count ;
 table  GENDER ALL, (CAMPUS all)*TERM*(count='#Enrl '*f=best8.*sum=' ' count=''*colpctsum='% Tot Enrl ' ) / rts=20;
run;

我的结果如下

                               campus
                             East Campus
                               Term
           Spring 2014               Spring 2015             Dfference
        #Enrl     %Tot_Enrl         #Enrl   %ToT_Enrl      #Enrl   %Tot_Enrl
Gender   
Female   8462      52.86             8429    52.36          -33       -37.08
Male     7478      46.71             7608    47.26          130       146.07
None     68        0.42              60      0.37            -8        -8.89
All      16008      100.00           16907    100.00        89          100

我需要在 '%Tot_Enrl' 变量中添加 % 符号。我也可以删除校园和学期名称吗?我有“校园”头衔和“东校区”头衔。所以我需要删除“校园”和“学期”。那可能吗?

4

1 回答 1

0

你需要更多=' '来摆脱 Campus 和 Term。要获得百分号,您需要一种格式;SAS 在这里向您展示如何

data want;
  format term $15. campus $15.;
  input term $ & campus $ & gender $ count;
  datalines;
Spring 2014  East Campus  Female 8462
Spring 2014  East Campus  Male 7478
Spring 2014  East Campus  None 68
Spring 2015  East Campus  Female 8429
Spring 2015  East Campus  Male 7608
Spring 2015  East Campus  None 60
Difference  East Campus  Female -33
Difference  East Campus  Male 130
Difference  East Campus  None -8
;;;;
run;



proc format;                           
   picture mypct(round) low-high='000,009.90%' (mult=100);   
run; 


proc tabulate data=want;
  class TERM CAMPUS GENDER ;
  var count ;
  table  GENDER ALL, (CAMPUS=' ' all)*TERM=' '*(count='#Enrl '*f=best8.*sum=' ' count=''*colpctsum='% Tot Enrl '*f=mypct. ) / rts=20;
run;

排序结果是错误的,我猜你有一个格式化的数字,但它让这个想法得到了理解。

于 2015-09-03T14:49:03.923 回答