02-15-2018 05:14 PM
Yes, but it would be easier if you get rid of the commas between the values. Here's some documentation:
02-15-2018 05:24 PM
Depends on how you want to use it. You may end up finding that a %DO loop may work just as well.
You can also check out examples 3 and 4 here:
02-16-2018 04:45 AM
It can be done as follows.
%macro combineYears(Year1, Year2, Year3, Year4, Year5); %do i=1 %to 5; %put year= &&year&i; /*process logic*/ %end; %mend combineYears; %combineYears(2000, 2001, 2010, 2015, 2018); *LOG year= 2000 year= 2001 year= 2010 year= 2015 year= 2018
It will be good if you also pass the number of years you are passing and use to loop control.
Please let us know if it helped.
02-16-2018 03:43 PM
@Satish_Parida your approach, while it will work would have issues if the user only wants to process 2 years and would require a diffent macro to process any different number of year.
This is what @Astounding meant by getting rid of commas:
%macro combineYears(YearList); %do i=1 %to %sysfunc(countw(&yearlist)); %put year= %scan(&yearlist,&i); /*process logic*/ %end; %mend combineYears; %combineYears(2000 2001 2010 2015 2018);
which will process any explicit list of one or more items. Note that we have no check for and empty list though nothing inside the %do loop will happen so likely okay for that, or checks to ensure that the values in the list are valid for any other purpose.