Help using Base SAS procedures

Question: UNIX SAS under the batch mode

Accepted Solution Solved
Reply
Contributor
Posts: 35
Accepted Solution

Question: UNIX SAS under the batch mode

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.


Accepted Solutions
Solution
‎06-27-2012 04:58 PM
Super User
Super User
Posts: 6,499

Re: Question: UNIX SAS under the batch mode

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


All Replies
Solution
‎06-27-2012 04:58 PM
Super User
Super User
Posts: 6,499

Re: Question: UNIX SAS under the batch mode

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;

PROC Star
Posts: 1,230

Re: Question: UNIX SAS under the batch mode

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;

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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