0

I want to change dataset names in SAS using concatenated macro variables. Using the example code below I get an error. Is my syntax wrong or is it not possible to use a concatenating function in this way?

Code:

 %let term=201610;
 %let emp='bob';

 Proc Datasets library=work;
 change testset = cat(&emp,&term);
 run;

Errors Received:

ERROR 22-322: Syntax error, expecting one of the following: ALTER, MEMTYPE, MT, MTYPE, PROTECT, PW, READ, WRITE.

ERROR 76-322: Syntax error, statement will be ignored.

1 Answer 1

1

You don't need to concatenate macro variables, it's like a find and replace text. Because you have quotes right now this is what would happen:

 change testset = cat('bob', 201610)

But the CAT function is not valid there. You could technically use %SYSFUNC() to use the CAT function but there's an easier way.

 %let term=201610;
 %let emp='bob';

 Proc Datasets library=work;
 change testset = &emp&term.;
 run;quit;

Note that PROC DATASETS requires a QUIT to terminate.

Sign up to request clarification or add additional context in comments.

2 Comments

The quotes around 'bob' need removing as well
Thanks, fixed it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.