12-30-2015 11:58 AM
input name$ rev id;
a 11121 123
b 32322 223
c 2323 345
select storename,storerev,storeid from t where storeid in(&id);
getting error and %put is not printing anything in log?
ERROR: More positional parameters found than defined.
12-30-2015 12:10 PM
Simply put: You have a comma that needs to be quoted. The Macro quoting is a huge topic, so please do RTM.
data t; input name$ rev id; cards; a 11121 123 b 32322 223 c 2323 345 ;run; %macro a(id); %put &id; proc sql; select * from t where id in(&id); %mend; %a(%str(123,223));
12-30-2015 12:31 PM
In more ugly detail: The default delimter between macro variables is a comma. When you used %a(123,223); you told the macro compiler that the value for parameter ID was 123 and then went on to provide the value, 223, for a different parameter but you did not define a second parameter.
Note that as of SAS 9.2 you do not need to delimit values when using IN comparisons in datastep or SQL. So %a( 123 223); should work.
If you need the list to have commas for another purpose then other approaches will be needed.