Hi,
I have two proc-tabulate-steps with separate where-filters. But actually I want just 1 table with the results of both tables:
Col2: bev
Col3: FPSchl*betrag where FPSchl="P9999"
col4: FPSchl*betrag where FPSchl="P1999";
So: Is this within one proc-tabulate-step doable?
proc tabulate data=Schulden out=test;
class namebst fpschl;
var betrag bev;
table NameBST, bev FPSchl*betrag;
where FPSchl="P9999";
run;
proc tabulate data=Schulden out=test2;
class namebst fpschl;
var betrag bev;
table NameBST, bev FPSchl*betrag;
where FPSchl="P1999";
run;
Seems to me it is this simple?
proc tabulate data=Schulden out=test;
class namebst fpschl;
var betrag bev;
table NameBST, bev FPSchl*betrag;
where FPSchl in ("P9999", "P1999");
run;
Depends on exactly what you expect for the results of other variables such as BEV. If you want BEV to have separate sums that match your separate tables then likely you could do:
proc tabulate data=Schulden out=test; class namebst fpschl; var betrag bev; table NameBST, FPSchl*(BEV betrag); where FPSchl in ("P9999", "P1999"); run;
You can nest and group lots of variables and statistics requests with ( ) for the groups.
It is best to either provide example data or use a SAS supplied data set for your examples. Here is similar code using the SASHELP.CLASS data set.
proc tabulate data=sashelp.class; class sex age; var height weight; table sex, weight age*height; where age=13; run; proc tabulate data=sashelp.class ; class sex age; var height weight; table sex, weight age*height; where age=14; run; proc tabulate data=sashelp.class ; class sex age; var height weight; table sex, age*(weight height); where age in (13, 14); run;
thank you for your answers. pretty helpful! that works!
Ive another question: I guess, proc tabulate doenst know such thing like "select distinct" for a specific column?
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 how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.