SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RandoDando
Pyrite | Level 9

I have a macro text value I have initiated with the %let statement.  The value is entered manually and then used throughout the code, including in a   ODS output statement where I have the macro value in the file name of the PDF.  However, each time I run this it does not read the macro value and outputs the macro name instead.  I know to use double quotes for these.  One of the folder names in the directory has a &  (unable to change that on my end).  Each time I export there I get warnings in my log about it not locating a macro, but I usually overlook it because I know it's a folder name.  It doesn't impact SAS's ability to find the location and export the file, however this is my first attempt in using a macro in the filename when exporting there.  Could that be affecting SAS's ability to read an actual macro in the filename statement? 

 

Have been unable to test other export locations as this is the only one I can map to at the moment.

 

%let IDvlue = XX999;


ods pdf file="\\....\OUTPUT_Table_&IDvlue.pdf";
...
1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

I believe you need an extra . period after the macro var reference i.e. 

%let IDvlue = XX999;


ods pdf file="\\....\OUTPUT_Table_&IDvlue..pdf";
...

View solution in original post

3 REPLIES 3
novinosrin
Tourmaline | Level 20

I believe you need an extra . period after the macro var reference i.e. 

%let IDvlue = XX999;


ods pdf file="\\....\OUTPUT_Table_&IDvlue..pdf";
...
RandoDando
Pyrite | Level 9
That was it. Thanks
ballardw
Super User

If you look in that folder you likely have a file without an extension the looks like Output_table_XX999pdf.

 

The dot character after a macro variable indicates the end of the macro variable name, almost like a concatenation.

If macrovar has the value of ABC then  &macrovar.XYZ resolves to ABCXYZ. Without the dot you would get an error for &macrovarXYZ that the macro variable MacrovarXYZ does not exist. So when you have a macro variable that has to be followed by a dot, such as in a file extension or a libname.data set name you need an extra dot. One to end the macro variable the next to be literal text.

 

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
  • 3 replies
  • 2496 views
  • 1 like
  • 3 in conversation