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).
It's expecting a sequential sequence, ie date1, date2, date3 is specified as date1-date3.
If it's not sequential, but the columns are side by side you can try a double dash.
%let criteria=(keep=M15201610--M30201602);
It's expecting a sequential sequence, ie date1, date2, date3 is specified as date1-date3.
If it's not sequential, but the columns are side by side you can try a double dash.
%let criteria=(keep=M15201610--M30201602);
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.