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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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