Hi Experts,
I have a question on proc tabulate.the data look like
data test;
do grp=1 to 6;
do flg='Yes','No';
do sec='dsfsa', 'fdafa', 'afafa';
output;
end;
end;
end;
run;
proc tabulate data=test;
class grp flg sec;
table grp *FLG ,sec='section'
* (n='n' * f=10. COLPCTN='%' * f=7.2 )/ misstext='0' rts=40;
run;
my o/p:
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ†
‚ ‚ section ‚
‚ ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‰
‚ ‚ afafa ‚ dsfsa ‚ fdafa ‚
‚ ‡ƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒ‰
‚ ‚ n ‚ % ‚ n ‚ % ‚ n ‚ % ‚
‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰
‚grp ‚flg ‚ ‚ ‚ ‚ ‚ ‚ ‚
‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‰ ‚ ‚ ‚ ‚ ‚ ‚
‚1 ‚No ‚ 1‚ 8.33‚ 1‚ 8.33‚ 1‚ 8.33‚
‚ ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰
‚ ‚Yes ‚ 1‚ 8.33‚ 1‚ 8.33‚ 1‚ 8.33‚
‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰
‚2 ‚No ‚ 1‚ 8.33‚ 1‚ 8.33‚ 1‚ 8.33‚
‚ ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰
‚ ‚Yes ‚ 1‚ 8.33‚ 1‚ 8.33‚ 1‚ 8.33‚
‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰
‚3 ‚No ‚ 1‚ 8.33‚ 1‚ 8.33‚ 1‚ 8.33‚
‚ ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰
‚ ‚Yes ‚ 1‚ 8.33‚ 1‚ 8.33‚ 1‚ 8.33‚
‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰
‚4 ‚No ‚ 1‚ 8.33‚ 1‚ 8.33‚ 1‚ 8.33‚
‚ ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰
‚ ‚Yes ‚ 1‚ 8.33‚ 1‚ 8.33‚ 1‚ 8.33‚
Šƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒŒ
but my desired o/p is
„ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ†
‚ ‚ section ‚
‚ ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‰
‚ ‚ afafa ‚ dsfsa ‚ fdafa ‚
‚ ‡ƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒ‰
‚ ‚ n ‚ % ‚ n ‚ % ‚ n ‚ % ‚
‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰
‚grp ‚flg ‚ ‚ ‚ ‚ ‚ ‚ ‚
‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‰ ‚ ‚ ‚ ‚ ‚ ‚
‚1 ‚No ‚ 1‚ 50.00‚ 1‚ 50.00‚ 1‚ 50.00‚
‚ ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰
‚ ‚Yes ‚ 1‚ 50.00‚ 1‚ 50.00‚ 1‚ 50.00‚
‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰
‚2 ‚No ‚ 1‚ 50.00‚ 1‚ 50.00‚ 1‚ 50.00‚
‚ ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰
‚ ‚Yes ‚ 1‚ 50.00‚ 1‚ 50.00‚ 1‚ 50.00‚
‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰
‚3 ‚No ‚ 1‚ 50.00‚ 1‚ 50.00‚ 1‚ 50.00‚
‚ ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰
‚ ‚Yes ‚ 1‚ 50.00‚ 1‚ 50.00‚ 1‚ 50.00‚
‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰
‚4 ‚No ‚ 1‚ 50.00‚ 1‚ 50.00‚ 1‚ 50.00‚
‚ ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒ‰
‚ ‚Yes ‚ 1‚ 50.00‚ 1‚ 50.00‚ 1‚ 50.00‚
Šƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒŒ
can i produce this kid of output by using proc report?
Thanks
Sam
Hi.
Your code is very close to accomplist what you wanted:
proc tabulate data=test;
class grp flg sec;
table grp *FLG ,sec='section'
* (n='n' * f=10. pctn<flg>='%' * f=7.2 )/ misstext='0' rts=40;
run;
Good luck!
Anca.
Hi.
Your code is very close to accomplist what you wanted:
proc tabulate data=test;
class grp flg sec;
table grp *FLG ,sec='section'
* (n='n' * f=10. pctn<flg>='%' * f=7.2 )/ misstext='0' rts=40;
run;
Good luck!
Anca.
Hi Anca,
Thank you !!! I Tried PCTN but i used wrong variable , i am applying on grp!!!! . Now i got what i want.
Is the same table can we generate using proc report. because i need to add another variable like sec(afafa,dsfsa ‚fdafa) , that varible name is mflag(Yes,NO). i am unable to do it in one table by using proc tabluate,
my final o/p with new added variable is shown like this
section mflag
grp flg afafa dsfsa fdafa Yes No
n % n % n % n % n %
1 No XX XX XX XX XX XX XX XX XX XX
Yes XX XX XX XX XX XX XX XX XX XX
I below is the code i am using but it throws a error in log:
proc tabulate data=subgrps;
class grp flg sec mflag;
table grp *flg ,sec=’Section’
* (n='n' * f=10. PCTN<FLG>='%' * f=7.2 ), mflag=’Mflag’
* (n='n' * f=10. PCTN<FLG>='%' * f=7.2 )/ misstext='0' rts=40;
run;
Thanks
Sam
Hi. glad it worked.
You need to remove the comma before the mflag = "Mflag" * (....);
Using this data:
data test;
do grp=1 to 4;
do flg='Yes','No';
do mflag = "Yes", "No";
do sec='dsfsa', 'fdafa', 'afafa';
output;
end;
end;
end;
end;
run;
proc tabulate data=test;
class grp flg sec mflag;
table grp *flg ,
sec="Section" * (n="n" * f=10. PCTN<FLG>="%" * f=7.2 )
mflag="Mflag" * (n="n" * f=10. PCTN<FLG>="%" * f=7.2 )
/ misstext="0" rts=40;
run;
Good luck.
Anca.
Thank you so much Anca. It worked!!!!! That is what exactly i want.
Regards
Sam.
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.