Hi,
I am trying to create an ODS destination file for the excel tagset using macro variables. The files contain data by site and patient, so would be:
Data_12_001.xls
Data_12_002.xls
Etc.
The siteid and subjid are in the file sitepatientlist.
I have the following code, which is not working:
data _null_;
do obsnum=1 to last by 1;
set outlib.sitepatientlist point=obsnum nobs=last;
%let parmSite = &siteid;
%let parmSubj = &subjid;
%let fpath = "U:\outputs\data_&parmSite.._&parmSubj..xls";
ODS TAGSETS.EXCELXP file=&fpath;
…etc
I get an unresolved reference for parmSite and parmSubj. I can see that they populate correctly in the %let statements, but the fpath does not resolve.
I have tried many variations - anybody have any ideas?
Thanks
While you didn't show all of your code, it appears that you are trying to both assign and use a macro variable within the same datastep. That won't work as the macro variable can only be accessed after that datastep.
Some alternatives are suggested in the following paper: http://www2.sas.com/proceedings/sugi31/115-31.pdf
I am guessing that you are trying to create the macro variables parmSite and parmSubj from the values of siteid and subjid. You are getting the errors because siteid and subjid are NOT macro variables.
In the data step you are looking for:
call symput(parmsite,siteid);
call symput(parmsubj,subjid);
run;
then your fpath assignment may work. Depending on length assignments and values you may want to use strip to remove unwanted blanks such as
call symput(parmsite,strip(siteid));
if you get unwanted spaces in the resolved value for fpath.
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.