@mikepep21 wrote:
Hello,
My example of the variables (date1, date2, ..., daten) should actually be more like (date1, second_date, the_third_date, dt_exited...). In other words, the variables wouldn't necessarily end with a number nor look the same. Would this affect the code you have? Sorry I haven't had a chance to try it out, I changed jobs and waiting to get a SAS license.
What I'm really looking for is to have some sort of loop in a data step, not necessarily just formats
Thanks.
You create a blank delimited list of variable names with PROC SQL INTO. This list of names when passed to the macro will be scanned to generate the code to create the new variable. One thing that could be a problem is your macro used the old-name+_FMT as the name of the new variable which could depending on the length of old name produce an invalid SAS name.
This modification uses _&i as the temporary name.
%macro dateformat(arg);
%local i var;
%let i = 1;
%let var = %scan(&arg,&i,%str( ));
%do %while(%superq(var) ne);
_&i = input(&var., MMDDYY10.) ;
drop &var.;
rename _&i = &var.;
%let i = %eval(&i + 1);
%let var = %scan(&arg,&i,%str( ));
%end;
%mend;
... View more