This is my code. I am recoding a bunch of variables (200 to be exact). I am using this code, because I was hoping to use the vlabel function, but sadly vlabel doesn't support labels with spaces and "-" in them.. it only supports numbers,digits and underscores. I am trying to figure out the easiest way to add the labels to my recoded variables. Can someone suggest something?
So in the example below. the label for olditem6_3_5 is "In the last 4 weeks, I ate apples."
Thus I want the label for item6_3_5 to be ""In the last 4 weeks, I ate apples. (recoded).
My current code:
%macro recode (indata=,var=);
DATA _null_;
SET &indata;
array vars(*) &var;
DO i=1 TO dim(vars);
call symput("mvNAME"||strip(i),strip(vname(vars(i))));
END;
call symput("mvNB",strip(dim(vars)));
RUN;
%DO b=1 %TO &mvNB;
data &indata;
set &indata;
array oldtest(*) old&&mvNAME&b;
array newtest(*) &&mvNAME&b;
call symput("mvLAB"||strip(i),strip(vname(old&&mvNAME&b));
DO z=1 TO dim(oldtest);
newtest(z)=6-oldtest(z);
END;
label &&mvNAME&b="&mvLAB (recoded)";
RUN;
%end;
%mend recode;
%recode (indata=temp,var=item6_3_5);
... View more