BookmarkSubscribeRSS Feed
tianerhu
Pyrite | Level 9

How to print Multiple datasets in one proc print statement?


data  females males;
   set apple.survey;
if  Gender = "F" then output females;
else if Gender = "M" then output males;
run;
proc print data = females;
run;
proc print data = males;
run;
9 REPLIES 9
novinosrin
Tourmaline | Level 20

To

How to print Multiple datasets in one proc print statement?

 

Do not split, rather sort and print to make it look multiple groups i.e

 

 

proc sort data=apple.survey out=want;

 by gender;

run;

proc print data =want;

run;

 

 

Astounding
PROC Star

If you go this route, you can add to the PROC PRINT step:

 

 

proc print data=want uniform;
   by gender;
   pageby gender;
run;
novinosrin
Tourmaline | Level 20

Thank you @Astounding  I learned something new viz. uniform option. Nice!

tianerhu
Pyrite | Level 9

thank you , but it does not work

tianerhu
Pyrite | Level 9

Thank you , but  it doesn't work .

PaigeMiller
Diamond | Level 26

@tianerhu wrote:

How to print Multiple datasets in one proc print statement?


data  females males;
   set apple.survey;
if  Gender = "F" then output females;
else if Gender = "M" then output males;
run;
proc print data = females;
run;
proc print data = males;
run;

So the answer has already been given above, but there is no reason whatsoever to split the data set into two in the first place, and then do the same thing on both splits. Usually this is very poor practice.

--
Paige Miller
tianerhu
Pyrite | Level 9

Thank you , but it doesn't work .

Reeza
Super User

PROC PRINT cannot print multiple data sets at once. If you have groups within your data, the SAS method for analysis is optimal when you do not split your data set into multiple data sets. Then you can use BY group processing. However, if you have split your data then you need to call PROC PRINT multiple times. This is a design choice, which is yours as the programmer.

 

 

tianerhu
Pyrite | Level 9

thank you .

SAS Innovate 2025: Call for Content

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!

Submit your idea!

What is Bayesian Analysis?

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.

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
  • 9 replies
  • 1971 views
  • 4 likes
  • 5 in conversation