SAS中文论坛
标题:
HELP: Question about proc tabulate
[打印本页]
作者:
shiyiming
时间:
2009-7-25 04:37
标题:
HELP: Question about proc tabulate
Dear friends,
I have a data set like this:
data setp.tt;
input id $2. group $2. status 1.;
cards;
aa 11 1
aa 11 0
aa 11 1
aa 11 0
aa 11 1
bb 11 1
bb 11 0
bb 11 0
bb 11 0
cc 11 1
cc 11 0
cc 11 0
dd 22 1
dd 22 0
dd 22 1
dd 22 0
ee 22 1
ee 22 1
ff 22 0
ff 22 0
ff 22 0
gg 22 1
gg 22 0
gg 22 0
gg 22 1
;
I want to use [b:3sib8p43]proc tabulate [/b:3sib8p43]to build a table like this:
total sum_1 percent
aa 5 3 60%
bb 4 1 25%
cc 3 1 33%
dd 4 2 50%
ee 2 2 100%
ff 3 0 0%
gg 3 2 67%
11 12 5 42%
22 13 6 46%
total 25 11 44%
How to write the code ? Thanks a lot.
作者:
shiyiming
时间:
2009-7-25 09:38
标题:
Re: HELP: Question about proc tabulate
怎么这么像作业题。
作者:
shiyiming
时间:
2009-7-26 11:28
标题:
Re: HELP: Question about proc tabulate
很奇怪,还真不知道pctsum<>的分母该写什么,应该能直接算的吧,谁知道说一声,谢谢
[code:1pbn8ri4]/* 加了个分析变量,给pctsum做分母 */
data work.tt;
input id $ group $ status;
temp=1;
cards;
aa 11 1
aa 11 0
aa 11 1
aa 11 0
aa 11 1
bb 11 1
bb 11 0
bb 11 0
bb 11 0
cc 11 1
cc 11 0
cc 11 0
dd 22 1
dd 22 0
dd 22 1
dd 22 0
ee 22 1
ee 22 1
ff 22 0
ff 22 0
ff 22 0
gg 22 1
gg 22 0
gg 22 1
;
proc format;
picture pct(round)
low-high='009%';
run;
proc tabulate data=work.tt ;
class id group;
var status temp;
table id='' (group='' all='total'),
status=''*(n*f=8. sum*f=8. pctsum<temp>*f=pct8.);
keylabel n='total'
sum='sum_1'
pctsum='percent'
;
run;[/code:1pbn8ri4]
作者:
shiyiming
时间:
2009-7-27 21:12
标题:
Re: HELP: Question about proc tabulate
Thanks a lot for reply. It works. I will apply it to my bigger data set.
欢迎光临 SAS中文论坛 (https://mysas.net/forum/)
Powered by Discuz! X3.2