So I have to do the exact same thing over and over again for multiple dataset, so I figured a macro might be helpful. This is the code I am trying to run.
%macro lab (fich, num);
data &fich;
set &fich;
if CRF&num=" " then CRF&num="MISSING";
%let &num=%eval(&num+1);
if CRF&num=" " then CRF&num="MISSING";
run;
%mend lab;
%lab(temp,55);
%lab(temp1,60);
So basically, I have variables (CRF55, CRF56, CRF57..and so on) that I want it to insert the word "MISSING" when the character value is blank. And then the same thing again for another dataset starting with var CRF60 (so this case will be CRF60, CRF61, CRF62 and so on). I have to do this for 4 varaibles per dataset and all in numerical order (e.g 55,56,57,58 and then another dataset for 60,61,62,63...etc.) Can someone suggests an easy way to do this without manually coding every dataset? The only other solution I can think of is create multiple datasteps and do the %let statement to change the num inbetween each datasets. but I feel there is a more efficient way to code this.
%macro lab (fich, num);
data &fich;
set &fich;
if CRF&num=" " then CRF&num="MISSING";
run;
%let &num=%eval(&num+1);
data &fich;
set &fich;
if CRF&num=" " then CRF&num="MISSING";
run;
%mend lab;
Thank you!!!
... View more