BookmarkSubscribeRSS Feed
Konkordanz
Pyrite | Level 9

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;

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

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;
ballardw
Super User

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;

 

Konkordanz
Pyrite | Level 9

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?

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 755 views
  • 2 likes
  • 3 in conversation