Help using Base SAS procedures

SAS set statement

Reply
Contributor
Posts: 44

SAS set statement

I am trying to use the set statement for multiple datasets in one shot namely I have datasets vmoreranked1,vmoreranked2,vmoreranked3,...But constantly getting an error

 data stackorig;
set vmoreranked1-vmoreranked&vmcnt; run;
                  -
                  22

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, ;, END, KEY, KEYS, NOBS, OPEN, POINT, DATA, LAST, NULL.

NOTE: The SAS System stopped processing this step because of errors.

Can someone help?

Super User
Posts: 19,789

Re: SAS set statement

What version of SAS do you have? This type of syntax is valid in SAS 9.3+

Super User
Posts: 3,252

Re: SAS set statement

This may be caused by &vmcnt not resolving correctly. Check by replacing this with a number like 2 just to see if it fixes the problem.

Super User
Posts: 5,504

Re: SAS set statement

My guess:  &VMCNT was created by PROC SQL and thus includes leading blanks.  The easiest way to overcome this is to add this statement before the DATA step:

 

%let vmcnt = &vmcnt;

 

Alternatively (depending on how much subsequent processing has taken place), you might be able to use &SQLOBS instead of &VMCNT.

Trusted Advisor
Posts: 1,137

Re: SAS set statement

I agree with @Astounding, may be there are leading blank spaces in the macro variable vmcnt, so try to use %cmpres function which will remove the blank if any.

data stackorig;
set vmoreranked1-vmoreranked%cmpres(&vmcnt);
run;
Thanks,
Jag
Ask a Question
Discussion stats
  • 4 replies
  • 261 views
  • 3 likes
  • 5 in conversation