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!
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.