03-12-2018 03:12 PM
I came across this question when trying to pull multiple datasets from the same data source. The question is how I can delimit the macro variables when the parameters are defined with multiple numeric values. Below is the example I have. When I tried to plug in the parameters with multiple values like idlist1 and idlist3, the macro cannot take it as the parameters have the same delimiter comma as that between the macro variables "datasetid" and "idlist".
%let idlist1=1111, 3333;
create table want_&datsetid. as
from libdat.datset_a a
inner join libdat.datset_b b on a.joinid = b.joinid
and b.idvar in (&idlist.)
Can anyone help?
Thanks a lot!
03-12-2018 03:49 PM
Ideally, you would create the original variables with a space as a delimiter:
%let idlist3=5555 6666 7777;
Then you would have no problem using &IDLIST3. as a macro parameter. Inside the macro you would have to create a second macro variable. Take 5555 6666 7777 and create a new macro variable with the value:
5555, 6666, 7777
Are your macro programming skills up to the task?
03-12-2018 03:54 PM
This is an arcane topic called "macro quoting". I suggest you read up on it in the SAS help.
I'm not an expert, so there may be a better way to do it, but I believe this will work:
%let idlist1=%str(1111, 3333);
Need further help from the community? Please ask a new question.