Here is some sample data:
data have;
infile datalines;
input Account Group M15201610 M15201611 M15201612 M30201601 M30201602;
datalines;
1 1 0 2 2 2 .
0 0 1 2 2 2 .
3 3 0 3 1 2 1
;
run;
Here is what I'm trying to do:
%let criteria=(keep=M15201610-M30201602);
data want;
set have &criteria.;
run;
Now, I am getting the error:
ERROR: Not all variables in the list M15201610-M30201602 were found.
When I put the range of variables as (keep= M15201610-M15201612), it works perfectly fine. The reason I'm doing this keep list in the macro variable is because my real data has many of these M variables and I don't want to have to list them out one by one. They represent dates at the middle of the month and end of month for each year and month. So M15201610 would be October 15, 2016. Is there any way I can get around this error? (don't ask why the dates are labeled this way, I didn't come up with the naming convention).