210 likes | 271 Views
Proc Logistic. Without specification, SAS models the first value of dependent variable as the “event”, in this case, y=0. proc logistic data = a.chd2018_a plots = none ; model chd =age; run ;.
E N D
Without specification, SAS models the first value of dependent variable as the “event”, in this case, y=0. • proclogisticdata= a.chd2018_a plots=none; • modelchd=age; • run;
Without specification, SAS models the first value of dependent variable as the “event”, in this case, y=“Developed Chd”. procfreqdata=s5238.chd2018; tableschd*age; run; proclogisticdata= s5238.chd2018 plots=none; modelchd=age; run;
Explicitly specify event value • proclogisticdata=a.chd2018_a plots=none; • modelchd(event="1")=age; • run;
Explicitly specify event value proclogisticdata= s5238.chd2018 plots=none; modelchd(event="Developed Chd")=age; run;
The descending option, in this case, the second value is modeled (y=1). proclogisticdata=a.chd2018_a plots=nonedescending; modelchd=age; run;
Scoring new data. datato_predict; do age=25to50; output; end; run; proclogisticdata=a.chd2018_a noprint; modelchd(event="1")=age; scoredata=to_predictout=tmplog; run; procprintdata=tmplog; run;
Scoring the data set used – the out= option • proclogisticdata=a.chd2018_a noprint; • modelchd(event="1")=age; • scoreout=tmplog; • run; • procprintdata=tmplog; • run;
Create a data set with estimated coefficients proclogisticdata=a.chd2018_a outest=betas noprint; modelchd(event="1")=age; run; procprintdata=betas; run;
Create a file of estimated parameters using ODS. odsoutputparameterestimates=betas; odsselectparameterestimates; proclogisticdata=a.chd2018_a; modelchd(event="1")=age; run; procprintdata=betas; run;
Create a file of estimated parameters using ODS.By group processing. procsortdata=a.chd2018_a out=tmp; by male; run; odsoutputparameterestimates=betas; odsselectparameterestimates; proclogisticdata=tmp; by male; modelchd(event="1")=age; run; procprintdata=betas; run;
Add covariance matrix to output. proclogisticdata=a.chd2018_a outest=betas covout; modelchd(event="1")=age; run; procprintdata=betas; format age 12.10; run;
Display covariance matrix. proclogisticdata=a.chd2018_a; modelchd(event="1")=age/covb; run;
Examine ODS output files. odstraceon; proclogisticdata=a.chd2018_a; modelchd(event="1")=age; run; odstraceoff;
Put fit statistics into a file odsoutputfitstatistics=likelihood; odsselectfitstatistics; proclogisticdata=a.chd2018_a; modelchd(event="1")=age; run; procprintdata=likelihood; run;
Specify plots. proclogisticdata=a.chd2018_a plots=effect; modelchd(event="Developed Chd")=age; run;
The freq statement procfreqdata=a.chd2018_a noprint; tables age*chd/out=chdagecnt; run; procprintdata=chdagecnt; run; proclogisticdata=chdagecnt; modelchd(event="Developed Chd")=age; freq count; run;
Create a binomial version of the data. Each observation is the number of observations and the number of events. procsql; createtable positives as selectage,count(*) as n1 from a.chd2018_a wherechd= 1 groupby age ; createtable counts as selectage,count(*) as n from a.chd2018_a groupby age ; createtable binary as select a.age,n1,n from positives a,counts b wherea.age=b.age ; select * from binary; quit;
odsselectparameterestimates; proclogisticdata=a.chd2018_a; modelchd(event="1")=age; run; odsselectparameterestimates; proclogisticdata=binary; model n1/n=age; run;