* Using macro variables to shorten code in comparison to if and else statements; data temp; input age; cards; 52 56 63 66 70 72 76 63 36 56 40 61 52 68 67 ; run; data time1; x1=time(); run; * create agegroup; * data step with if and else statements; data temp1; set temp; if 30<=age<35 then age10=1; else if 35<=age<40 then age10=2; else if 40<=age<45 then age10=3; else if 45<=age<50 then age10=4; else if 50<=age<55 then age10=5; else if 55<=age<60 then age10=6; else if 60<=age<65 then age10=7; else if 65<=age<70 then age10=8; else if 70<=age<75 then age10=9; else if 75<=age<80 then age10=10; run; data time2; set time1; x2=time(); time21=(x2-x1);* time21= how long it takes for temp1; run; data time3; set time2; x3=time(); run; * create macro variable; data macro1; input level age; call symput('agegp'||left(level),put(age,best.)); cards; 1 30 2 35 3 40 4 45 5 50 6 55 7 60 8 65 9 70 10 75 ; run; * create agegroup using the macro variable; data temp2; set temp; do i=1 to 10; if age>=input(symget('agegp'||trim(left(i))),best.) then age10=i; else age10=age10; end; run; data time4; set time3; x4=time(); time43=(x4-x3);* time43= how long it takes for temp2; run; proc print data=time4; var time21 time43; run; /*data smpt4; input level fhdl fsbp1 fsbpt1 fsbp2 fsbpt2 fage101 fage102 fsmk1 fsmk2 fchol101 fchol102 fchol103 fchol104 fchol105 fchol201 fchol202 fchol203 fchol204 fchol205;; call symput('fhdl'||left(level),put(fhdl,best.)); call symput('fsbp1'||left(level),put(fsbp1,best.)); call symput('fsbpt1'||left(level),put(fsbpt1,best.)); call symput('fsbp2'||left(level),put(fsbp2,best.)); call symput('fsbpt2'||left(level),put(fsbpt2,best.)); call symput('fage101'||left(level),put(fage101,best.)); call symput('fage102'||left(level),put(fage102,best.)); call symput('fsmk1'||left(level),put(fsmk1,best.)); call symput('fsmk2'||left(level),put(fsmk2,best.)); call symput('fchol101'||left(level),put(fchol101,best.)); call symput('fchol102'||left(level),put(fchol102,best.)); call symput('fchol103'||left(level),put(fchol103,best.)); call symput('fchol104'||left(level),put(fchol104,best.)); call symput('fchol105'||left(level),put(fchol105,best.)); call symput('fchol201'||left(level),put(fchol201,best.)); call symput('fchol202'||left(level),put(fchol202,best.)); call symput('fchol203'||left(level),put(fchol203,best.)); call symput('fchol204'||left(level),put(fchol204,best.)); call symput('fchol205'||left(level),put(fchol205,best.)); cards; 1 2 0 0 0 0 -9 -7 8 9 0 4 7 9 11 0 4 8 11 13 2 1 0 1 1 3 -4 -3 8 9 0 4 7 9 11 0 4 8 11 13 3 0 1 2 2 4 0 0 5 7 0 3 5 6 8 0 3 6 8 10 4 -1 1 2 3 5 3 3 5 7 0 3 5 6 8 0 3 6 8 10 5 . 2 3 4 6 6 6 3 4 0 2 3 4 5 0 2 4 5 7 6 . . . . . 8 8 3 4 0 2 3 4 5 0 2 4 5 7 7 . . . . . 10 10 1 2 0 1 1 2 3 0 1 2 3 4 8 . . . . . 11 12 1 2 0 1 1 2 3 0 1 2 3 4 9 . . . . . 12 14 1 1 0 0 0 1 1 0 1 1 2 2 10 . . . . . 13 16 1 1 0 0 0 1 1 0 1 1 2 2 ; run; */