Hello everyone,
I am using tagsets.excelxp to push a dataset from Unix to Excel. I am trying to use a macro for the 'sheet_name' within the options as shown below. The macro variable 'year' has the value of 2012 and it works everywhere else. The proc report and the rest of the code works too. The only issue is the sheet name is showing up in the output Excel as "&year" instead of the value it should be (2012). Does anyone have any suggestions on how to use the macro variable on the 'sheet_name'? I really appreciate any input you may have. Thank you
ods listing close;
ods tagsets.excelxp file = "&work_path.ytd_&year.xls"
options(embedded_titles='No'
sheet_interval= 'none'
sheet_name='&year'
gridlines='Yes'
wraptex='Off'
suppress_bylines = 'yes'
)
style=sansprinter;
proc report data = ******
******
ods tagsets.excelxp close;
Hi:
Does the FILE= option reference to &YEAR work? I would expect that it works OK. You can figure this out, if you ask yourself, what is the difference betwen the specification for FILE= and the reference for SHEET_NAME=?
One of the first rules of macro variable reference is that &MACVAR references will NOT resolve if enclosed in SINGLE quotes. Your suboption value for SHEET_NAME could use DOUBLE quotes (like your FILE=).
Give it a try.
cynthia
Hi:
Does the FILE= option reference to &YEAR work? I would expect that it works OK. You can figure this out, if you ask yourself, what is the difference betwen the specification for FILE= and the reference for SHEET_NAME=?
One of the first rules of macro variable reference is that &MACVAR references will NOT resolve if enclosed in SINGLE quotes. Your suboption value for SHEET_NAME could use DOUBLE quotes (like your FILE=).
Give it a try.
cynthia
Thank you Cynthia! I changed the single quotes to double quotes and it worked!
I really appreciate your help!
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.