BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bigbigben
Obsidian | Level 7

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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;

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

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;

Quentin
Super User

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;

The Boston Area SAS Users Group is hosting free webinars!
Next up: Troy Martin Hughes presents Calling Open-Source Python Functions within SAS PROC FCMP: A Google Maps API Geocoding Adventure on Wednesday April 23.
Register now at https://www.basug.org/events.

sas-innovate-white.png

Special offer for SAS Communities members

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.

 

View the full agenda.

Register now!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1033 views
  • 0 likes
  • 3 in conversation