Dear All,
I've already created a Temp dataset from proc tabulate procedure show as follows, Can i use any Proc procedures to return the Temp datasets back into the original table created by Proc tabulates?
Any advice to do it?
Thank you all.
Eric
step1:
proc tabulate data=sashelp.class out=temp;
class age sex;
table age='',sex=''*N='';
run;
temp datasets looks like this
step2:
proc XXX data=temp;run;
I am looking for the results like this
Hi @EC189QRW
Please try PROC TABULATE:
proc transpose data=temp out=want (drop=_:);
var N;
by age;
id sex;
run;
NB: you could also directly use a PROC REPORT:
proc report data=sashelp.class out=want;
column age sex;
define age / group '';
define sex / across '';
run;
Best,
hi there, thank you for your quick reply. I found the transpose procedure doesn't work when the categorical variable have more than 2 different types.
data class; set sashelp.class; if height<=55 then h='01 L'; else if height<=60 then h='02 M'; else h='03 H'; run;
proc tabulate data=class out=temp; class age sex h; table age='',h=''*N=''; run;
proc transpose data=temp out=want (drop=_:); var N; by age; id h; run; proc print data=want;run;
Hi @EC189QRW
Could you pease post your log?
Here is what I get when I run the code:
data class;
set sashelp.class;
if height<=55 then
h='01 L';
else if height<=60 then
h='02 M';
else
h='03 H';
run;
proc tabulate data=class out=temp;
class age sex h;
table age='', h=''*N='';
run;
proc transpose data=temp out=want (drop=_:);
var N;
id h;
by age;
run;
proc print data=want;
Best,
You're very welcome @EC189QRW 😊
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.