BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
yelkenli
Calcite | Level 5

I have the below code and output, but would like to remove some of the variables in the printed tables and put in a series of titles at the top of each worksheet.  

Can this be done in one proc print step, or do I need some looping program?

 

 

ods tagsets.excelxp file="user/high_runs.xml" 
			style=styles.plateau
			options(sheet_interval='BYGROUP' sheet_name='#byval1');
proc print data=high_runs;
    by high_group;
run;
ods tagsets.excelxp close;

the output (the high_runs dataset would be this table, but with the high_group variable)

 

prod_nameprod_numberprod_type_nameprod_costlocal_dttmqty_aqty_b
prod11001small2302MAY2021:21:10:00.000000165373
prod11001small2302MAY2021:21:20:00.000000381555
prod21002med2402MAY2021:21:30:00.000000414658
prod21002med2402MAY2021:21:40:00.0000006801106
prod21002med2402MAY2021:21:50:00.0000006351052
prod21002med2402MAY2021:22:00:00.000000517812
prod31003large2502MAY2021:22:10:00.0000006411043
prod31003large2502MAY2021:22:20:00.0000006811642
prod31003large2502MAY2021:22:30:00.0000008781689
prod31003large2502MAY2021:22:40:00.00000011301547
prod31003large2502MAY2021:22:50:00.00000012941477

Wanted: 

prod_name:  prod1  
prod_number:  1001  
prod_type_name:  small  
prod_cost:  23  
   
local_dttmqty_aqty_b
02MAY2021:21:00:00.00000069173
02MAY2021:21:10:00.000000165373
   
next worksheet  
prod_name:  prod2  
prod_number:  1002  
prod_type_name:  med  
prod_cost:  224  
   
local_dttmqty_aqty_b
02MAY2021:21:20:00.000000381555
02MAY2021:21:30:00.000000414658
02MAY2021:21:40:00.0000006801106
02MAY2021:21:50:00.0000006351052

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

See if this gives you some clues:

 

Proc sort data=sashelp.class out=work.class;
   by sex age;
run;

options nobyline;
Title "Class report";
title2"#bvar1: #byval1";
title3"#byvar2: #byval2";

proc print data=work.class noobs;
   by sex age;
run;

options byline;

Since you can have 9 title statements you have a fair amount of lee-way to play with if you want multiple variables "removed" from the body to a separate line each. So sort your data by the 4 variables and use all 4 on the By statement. The option nobyline suppresses the default behavior of including BY var1 var2 in the output so you provide what you want using #byval and #byvar.

Note if your byvar names aren't as pretty as you want for the report you could provide any text you want instead of #byvar

View solution in original post

1 REPLY 1
ballardw
Super User

See if this gives you some clues:

 

Proc sort data=sashelp.class out=work.class;
   by sex age;
run;

options nobyline;
Title "Class report";
title2"#bvar1: #byval1";
title3"#byvar2: #byval2";

proc print data=work.class noobs;
   by sex age;
run;

options byline;

Since you can have 9 title statements you have a fair amount of lee-way to play with if you want multiple variables "removed" from the body to a separate line each. So sort your data by the 4 variables and use all 4 on the By statement. The option nobyline suppresses the default behavior of including BY var1 var2 in the output so you provide what you want using #byval and #byvar.

Note if your byvar names aren't as pretty as you want for the report you could provide any text you want instead of #byvar

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 644 views
  • 0 likes
  • 2 in conversation