BookmarkSubscribeRSS Feed
acordes
Rhodochrosite | Level 12

The following code extract creates for each cod_mrc and _fec_unic combination a worksheet.

But I want to add a sheet only triggered by the first by group, here cod_mrc.

 

A workaround is to eliminate the second by group from the by statement and use it in the where clause (repeating the proc report block 5 times) so that I get 5 months of 2023 stacked in one sheet. 

 

But is there an easy way? 

 

ods _all_ close;
ods excel file='/caslibs/marketing/compared3.xlsx';
ods excel options( sheet_name='Brand: #byval1'); 

options missing=0;
proc report data=ONAIR.SUM_HIERARCHY2(rename=('_Ventas Retail VN'n=fin '_Uds Retail VN'n=ren 'Ventas Retail VN'n=myfin 'Uds Retail VN'n=myren )) spanrows 
nowd center out=three completerows;
by cod_mrc _fec_unic ;
where year(_fec_unic) = 2023 and _fec_unic le '30apr2023'd ;
format _fec_unic monyy.;
1 REPLY 1
Tom
Super User Tom
Super User

I am not sure I follow what you are asking for.

 

But why not just remove the second variable from the BY statement?

 

If you want the sheet to change use the SHEET_INTERVAL option of ODS EXCEL.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 626 views
  • 0 likes
  • 2 in conversation