01-04-2012 10:44 AM
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:
The siteid and subjid are in the file sitepatientlist.
I have the following code, which is not working:
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;
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?
01-04-2012 10:50 AM
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
01-04-2012 11:58 AM
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:
then your fpath assignment may work. Depending on length assignments and values you may want to use strip to remove unwanted blanks such as
if you get unwanted spaces in the resolved value for fpath.