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 ! Check out recordings of our past webinars: https://www.basug.org/videos. Save the date for our in person SAS Blowout on Oct 18 in Cambridge, MA. Registration opens in September.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 805 views
  • 0 likes
  • 3 in conversation