2017-10-13 51 views
0

我有一組的前置和後置的分數,其值,可以是1或2,例如:
預發佈
2×2表與頻率和整體百分比在SAS - proc列表?

我需要創建一個2x2表,其中列出了頻率,只有在總的行/列百分比:

  1   2  Total 
1   14   60  74/30% 
2   38   12  50/20% 
Total 52/21% 72/29% 248 

它不需要用n和百分比之間的/特定格式,它們可以在不同的行上。我只需要確保表中的總百分比(無累積百分比)。

我認爲我應該使用proc tabulate來得到這個,但我是SAS新手,一直沒能弄明白。任何幫助將不勝感激。

代碼我已經試過:

proc tabulate data=.bilirubin order=data; 
    class pre ; 
    var post ; 
    table pre , post*(n colpctsum); 
run; 
+0

你有什麼'PROC TABULATE'試過這麼遠?你當然是正確的,可以在那裏做。 – Joe

+0

我得到的唯一的東西是這樣的,但它不會給我一個2x2表或者給我最低行的百分比: proc tabulate data = .bilirubin order = data; \t class pre; \t var post; \t表前,後*(n colpctsum); 跑; –

+0

嘗試使用PROC FREQ來代替嗎?您可以控制使用OUTPCT報告的百分比 – Reeza

回答

0

你可以讓自己的報表。例如,您可以使用PROC SUMMARY獲取頻率。添加一個數據步驟來計算百分比並用您想要顯示的文本生成一個字符變量。然後使用PROC REPORT來顯示它。

proc summary data=have ; 
    class pre post ; 
    output out=summary ; 
run; 
proc format ; 
    value total .='Total (%)'; 
run; 
data results ; 
    set summary ; 
    length display $20 ; 
    if _type_=0 then n=_freq_; 
    retain n; 
    if _type_ in (0,3) then display = put(_freq_,comma9.); 
    else display = catx(' ',put(_freq_,comma9.),cats('(',put(_freq_/n,percent8.2),')')); 
run; 
proc report missing data=results ; 
    column pre display,post n ; 
    define pre/group ; 
    define post/across ; 
    define n/noprint ; 
    define display/display ' '; 
    format pre post total.; 
run; 

enter image description here