Hi, guys:
There is a weird problem I run into when I run SAS on a unix server under the batch mode. The code runs perfectly under the interactive mode, but the batch mode create some extra spaces between words, which causes trouble.
There is a line in my code to read a dataset whose name are pre-specified by some macro variable. For example, I have a macro variable xx1=NewYork
The line of code is
data xxx; set tmp.&xx1._out; run;
The SAS code after parsing the macro variable turns out to be
data xxx; set tmp.NewYork _out;run;
In my case, NewYork_out is supposed to be a single dataset under the directory of tmp; however, the system read NewYork and _out as two separate words and search tmp.NewYork and work._out separately.
Have any of you encountered similar problems?
Thanks for yoru input.
Not sure why batch mode would effect this but it looks like one of two issues.
1) Macro variable XX1 actually contains one or more trailing spaces. Try %let xx1=&xx1; to remove any leading or trailing blanks.
2) The parser is getting confused and sticking a hard token break between the macro variable and the underscore.
Try assigning to a new macro variable.
%let inds=tmp.&xx1._out;
data xxx; set &inds; run;
Or try using %unquote() function.
data xxx; set tmp.%unquote(&xx1._out); run;
Not sure why batch mode would effect this but it looks like one of two issues.
1) Macro variable XX1 actually contains one or more trailing spaces. Try %let xx1=&xx1; to remove any leading or trailing blanks.
2) The parser is getting confused and sticking a hard token break between the macro variable and the underscore.
Try assigning to a new macro variable.
%let inds=tmp.&xx1._out;
data xxx; set &inds; run;
Or try using %unquote() function.
data xxx; set tmp.%unquote(&xx1._out); run;
If you do
%put >>&xx1.<< ;
What do you see? Do you see the extra blank at then end? if so, I would tr %trim(), or even just:
%let xx1=&xx1;
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.