data framing; infile 't:\framing.txt' firstobs=2; input id sex age frw sbp sbp10 dbp chol cig chd yrschd death yrsdth cause; if chd=1 then chdny=.; if chd=0 then chdny=0; if chd>1 then chdny=1; /* Vi laver en ny rygevariabel */ if cig>0 then smoke=1; if cig=0 then smoke=0; if cig=. then smoke=.; run; /* Spm. 1: køn vs. hjertesygdom stratificeret for smoke. */ proc freq data=framing; tables smoke*sex*chdny/chisq measures nocol nopercent cmh; run; /* Spm. 1: smoke vs. hjertesygdom stratificeret for køn. */ proc freq data=framing; tables sex*smoke*chdny/chisq measures nocol nopercent cmh; run; /* Spm. 2: konstruktion af grupperet aldersvariabel - NB nyt 'data step' */ data framing; set framing; if age<=48 then ageny=1; if age > 48 and age<=52 then ageny=2; if age > 52 and age<=56 then ageny=3; if age > 56 then ageny=4; run; /* Spm. 2: analyse af alder vs. hjertesygdom. */ proc freq data=framing; tables ageny*chdny/chisq measures; run; /* Smp. 3: logistiske regressioner */ proc genmod data=framing descending; class sex; model chdny=sex/dist=bin; estimate 'm vs. f' sex 1 -1 /exp; run; proc genmod data=framing descending; class smoke; model chdny=smoke/dist=bin; estimate 'smoke vs. no smoke' smoke -1 1 /exp; run; proc genmod data=framing descending; class ageny; model chdny=ageny/dist=bin; estimate '4 vs. 1' ageny -1 0 0 1 /exp; estimate '3 vs. 1' ageny -1 0 1 0 /exp; estimate '2 vs. 1' ageny -1 1 0 0 /exp; run; proc genmod data=framing descending; class sex smoke ageny; model chdny=sex smoke ageny/dist=bin; estimate 'smoke vs. no smoke' smoke -1 1 /exp; estimate 'm vs. f' sex 1 -1 /exp; estimate '4 vs. 1' ageny -1 0 0 1 /exp; estimate '3 vs. 1' ageny -1 0 1 0 /exp; estimate '2 vs. 1' ageny -1 1 0 0 /exp; run; /* spm. 4 */ /* Vi ser først på fordelingen af SBP */ proc univariate data=framing; var sbp; run; /* og vælger at dele ved 120, 140 og 180 mmHg */ data framing; set framing; if sbp<=120 then sbpny=0; if 120180 vs. <120' sbpny -1 0 0 1/exp; run; proc genmod data=framing descending; class sbpny sex ageny; model chdny=sbpny sex ageny/dist=bin type3; estimate '120-140 vs. <120' sbpny -1 1 0 0/exp; estimate '140-180 vs. <120' sbpny -1 0 1 0/exp; estimate '>180 vs. <120' sbpny -1 0 0 1/exp; estimate 'm vs. f' sex 1 -1 /exp; estimate '4 vs. 1' ageny -1 0 0 1 /exp; estimate '3 vs. 1' ageny -1 0 1 0 /exp; estimate '2 vs. 1' ageny -1 1 0 0 /exp; run;