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;

BASUG is hosting free webinars Next up: Mark Keintz presenting History Carried Forward, Future Carried Back: Mixing Time Series of Differing Frequencies on May 8. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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