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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 1 reply
  • 260 views
  • 0 likes
  • 2 in conversation