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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 2041 views
  • 4 likes
  • 5 in conversation