BookmarkSubscribeRSS Feed
LouiseH2010
Fluorite | Level 6

Hi,

 

I am trying create an excel report where each tab contains several reports where a new tab is created depening on the value within a macro field. The report itself is a macro that is called several times per tab and the call contains the value that names the tab.

 

Below is a simplified version of the code:

ods tagsets.excelxp file= "&outpath\&jn - &title Rolling 13 Months &sysdate..xls"

options(sheet_interval = "none"

embedded_titles = "yes"

embedded_footnotes = "yes"

skip_space = '0,0,0,0,0');

%macro all_report(product,characteristic,title3,char_format);

%macro dummy;

%mend dummy;

ods tagsets.excelxp options(sheet_interval = "none"

sheet_name="&Product."

 

);

Proc report data=SAS_DATA.rfv_storecards_all_months_&product. nowd;

title1 justify=left " ";

title2 justify=left " ";

title3 justify=left "&title3.";

Columns customergroup &characteristic._&dt_month3_year3. &characteristic._&dt_month2_year2. &characteristic._&dt_month1_year1.

&characteristic._&dt_month0_year0.;

Define customergroup / order order=internal "Customer Group";

Define &characteristic._&dt_month3_year3. / group "&dt_month3_year3." style(column)={tagattr=&char_format.};

Define &characteristic._&dt_month2_year2. / group "&dt_month2_year2." style(column)={tagattr=&char_format.};

Define &characteristic._&dt_month1_year1. / group "&dt_month1_year1." style(column)={tagattr=&char_format.};

Define &characteristic._&dt_month0_year0. / group "&dt_month0_year0." style(column)={tagattr=&char_format.};

run;

%mend;

%all_report(retailer1,customer,Customers,'format:#,##');

%all_report(retailer1,netsales122,Net Sales,'format:£#,##0,00');

%all_report(retailer1,trans122,Transactions,'format:#,##');

%all_report(retailer1,ATV,ATV,'format:£#,##0.00');

%all_report(retailer1,ASS,ASS,'format:£#,##0.00');

%all_report(retailer2,customer,Customers,'format:#,##');

%all_report(retailer2,netsales122,Net Sales,'format:£#,##0,00');

%all_report(retailer2,trans122,Transactions,'format:#,##');

%all_report(retailer2,ATV,ATV,'format:£#,##0.00');

%all_report(retailer2,ASS,ASS,'format:£#,##0.00');

ods _all_ close;

 

 

What I want to end up with is a tab called 'retailer1' with 5 reports on it and a second tab called 'retailer2' with 5 reports on it. The variable 'product' in the call statement holds the name for the tab. I have tried several places to put the sheet-Interval and sheet_name options but no joy yet.

 

Any ideas?

 

many thanks

6 REPLIES 6
Reeza
Super User
Try setting sheet_label to blank as well and change the sheet_interval to Now in the macro.

ods tagsets.excelxp options(sheet_interval = "now"

sheet_name="&Product."



);

And you really shouldn't nest macro's within each other, that's a recipe for problems.
LouiseH2010
Fluorite | Level 6

Hiya,

 

Thank you so much for your response - I have tried this in several different places and no luck. I either get 10 tabs with 1 report per tab or 1 tab for the first retailer and all 5 reports and nothing for the second retailer.

 

By nested macro's are you referring to the dummy macro as this is purely to get the colours in the code to be present to make it easier to read. 

 

Thanks

Reeza
Super User
Check your version of the tagsets, it shows up in the log. It should be 1.131 or 2015 - something like that.
Reeza
Super User
Add another parameter to your macro call, that controls the sheet interval.

When you want to start a new sheet have it called now. At the bottom of the macro reset it back to none so that you always have to specify it at the top of the macro.

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
  • 6 replies
  • 1631 views
  • 0 likes
  • 2 in conversation