Hi All,
i have the following dataset
data have ; input sub sex $ race $ trtan; cards; 111 M AA 1 112 F AS 2 113 F W 3 114 M AS 3 ; run;
How can i generate the following lines of code based on the categorial variable supplied by the user;
Two Groups (trtan and sex) %macro want(indsn=have , grp=trtan sex);
data want; set have;
/*The macro should generate the following lines based the GRP parameters supplied in the macro WANT*/
if upcase(sex) = "M" and trtan=1 then trt=1; if upcase(sex) = "M" and trtan=2 then trt=2; if upcase(sex) = "M" and trtan=3 then trt=3;
if upcase(sex) = "F" and trtan=1 then trt=4; if upcase(sex) = "F" and trtan=2 then trt=5; if upcase(sex) = "F" and trtan=3 then trt=6; run;
%macro want(indsn=have , grp=trtan sex race);
Three Groups (trtan , Race and sex)
data want; set have; /*The macro should generate the following lines based the GRP parameters supplied in the macro WANT*/
if upcase(sex) = "M" and trtan=1 and race = "AA" then trt=1; if upcase(sex) = "M" and trtan=2 and race = "AS" then trt=2; if upcase(sex) = "M" and trtan=3 and race = "W" then trt=3;
if upcase(sex) = "F" and trtan=1 and race = "AA" then trt=4; if upcase(sex) = "F" and trtan=2 and race = "AA" then trt=5; if upcase(sex) = "F" and trtan=3 and race = "AA" then trt=6; run;
... View more