BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
KevinC_
Fluorite | Level 6

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 Smiley Happy

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

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

View solution in original post

2 REPLIES 2
Cynthia_sas
SAS Super FREQ

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

KevinC_
Fluorite | Level 6

Thank you Cynthia!  I changed the single quotes to double quotes and it worked!

I really appreciate your help! Smiley Happy

sas-innovate-2024.png

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.

 

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