将百分比%添加到proc表格报告中

时间:2015-09-03 14:26:39

标签: sas enterprise-guide

我有一个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'中添加%符号。变量。 我还可以删除校园和学期标题吗?我有校园'标题和东校区'标题。所以我需要删除校园'和' Term'。那可能吗?

1 个答案:

答案 0 :(得分:0)

您需要更多=' '来摆脱校园和学期。要获得百分号,您需要一种格式; SAS shows you how here

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;

排序结束时出错了,我猜测你有一些格式化的数字,但它可以解决这个问题。