user6016731
user6016731

Reputation: 382

Set statement SAS with multiple datasets generating ERROR 22-322: Syntax error

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?

Upvotes: 0

Views: 1001

Answers (1)

Tom
Tom

Reputation: 51621

Unless you are running an old version of SAS that does not support using ranges of dataset names then you probably have leading spaces in your macro variable. For example if I run this code:

data _null_;
  call symput('vmcnt','   2');
run;

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

I get your error message, but I also get another message that explains the problem.

2071  vmoreranked   2
                    -
                    22
                    200
ERROR: Missing numeric suffix on a numbered data set list (WORK.vmoreranked1-WORK.vmoreranked).
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, ;, CUROBS,
              END, INDSNAME, KEY, KEYRESET, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_.

ERROR 200-322: The symbol is not recognized and will be ignored.

You should fix how you are creating macro variable so that the leading spaces are not included.

Or you can just remove the leading spaces by re-creating it like this:

%let vmcnt=&vmcnt ;

Upvotes: 0

Related Questions