0% found this document useful (0 votes)
200 views33 pages

S A S Guide

SAS Guide

Uploaded by

kprdeepak
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
200 views33 pages

S A S Guide

SAS Guide

Uploaded by

kprdeepak
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 33

Copyright mh2007

Table of Contents
Section 1 Preliminaries 1.1 Getting Started with SAS 1.2 More on Data Management by Example Section 2 Parametric Tests 2.1 Getting A !"ainted with the #$te%t 2.2 A&'(A by Example 2.) *inear +egre%%ion by Example Section 3 Nonparametric Tests ).1 ,il oxon +an- S"m #e%t and .r"%-al$,alli% #e%t by Example Section 4 Logistic Regression /.1 *ogi%ti +egre%%ion by Example

Section 1

Preliminaries

1.1 Getting Started Wit S!S 'ne o0 the 0ir%t thing% to on%ider prior to reating a data %et i% to -now what in0ormation yo" wo"ld li-e on1eyed. #he bigge%t problem that re%ear her% ha1e i% oming "p with a lear and on i%e !"e%tion and %ti -ing to it. 2nder the a%%"mption that the data o0 intere%t ha% already been obtained thro"gh a primary %o"r e 3yo"r own data olle tion te hni!"e4 or a %e ondary %o"r e 3another in1e%tigator% data or maybe data on the internet45 yo" now m"%t be able to bring thi% data into a "%able 0ormat. #hi% i% re0erred to a% reating a data %et. #he 0ollowing %tep% are help0"l6 "sing S!S 7ir%t5 name the data %et yo" wo"ld li-e to reate.
data one;

#he 0ollowing data %et i% gi1en the name5 one. #he data %et5 one5 i% empty 0or the moment "ntil a t"al raw data an be bro"ght in. 8e0ore going any 0"rther5 one important thing to remember when "%ing SAS i% to p"t a %emi olon a0ter ea h %tatement. #hi% an get tedio"% at time%5 b"t i% %omething that %ho"ld be -ept in mind be0ore %tarting anything in SAS. 9n order to bring in yo"r data a 1ariety o0 po%%ibilitie% are a1ailable. 'ne method i% to -eyp"n h yo"r data dire tly into SAS. 8e0ore yo" %tart yo" m"%t "%e the inp"t ommand a% in the 0ollowing line6
input Sub_name $ weight age;

#he inp"t ommand let% SAS -now not only the 1ariable name 0or ea h o0 the ol"mn% o0 yo"r data b"t al%o the type o0 data yo" will be bringing in. #he two type% o0 data that we will be on erned with i% hara ter and n"meri . 7rom the inp"t line5 it i% ea%ily noti ed that S"b:name i% yo"r 0ir%t ol"mn 1ariable5 and will re0er to the %"b;e t<% name. Sin e name% are hara ter data5 we need to let SAS -now thi%. #hi% i% a ompli%hed with the "%e o0 the 3=4. &ow SAS -now% it will be reading in hara ter or alpha n"meri data 0or the 1ariable S"b:name. #he other 1ariable%6 height5 weight5 and treat5 will be on%idered n"meri . 'ne thing to note i% that SAS i% apable o0 reading in 0ormat type% other than hara ter and n"meri data. 9t an read in date% 0or example5 b"t we will lea1e that i%%"e 0or a later di% "%%ion. 'n e SAS -now% what type o0 data yo" will be "%ing5 and be0ore the -eyp"n hing pro e%% an begin a dataline% %tatement i% re!"ired.
datalines;

#he dataline% %tatement let% SAS -now where the raw data exi%t% and will be read 0rom. A0ter the dataline% %tatement5 yo" an begin the -eyp"n hing pro e%% "%ing a %pa e a% a delimiter5 whi h allow% SAS to di%ting"i%h between the di00erent 1ariable% yo" are p"n hing in data 0or. #he 0ollowing i% an example o0 %ome ob%er1ation line%6

JaySmith MaryCarr JoeJones ;

125 22 115 20 177 !

&oti e that the data a0ter being -eyp"n hed in wa% 0ollowed by a %emi olon. #hi% indi ate% that there will be no more re ord% entered and that SAS ha% rea hed the end o0 the raw data %et. 'n e the%e %tep% ha1e been ompleted pro ed"re %tatement% alled pro %tatement% an be "%ed to 1iew5 manip"late5 or analy>e the data. .eep in mind that a ?r"n@ %tatement "%"ally 0ollow% all pro %tatement%. Ao" an "%e the 0ollowing pro %tatement% to 1iew the ontent% o0 what SAS ha% read into data %et one6
proc print; run;

90 yo" are "%ing the window% 1er%ion o0 SAS5 ;"%t point to the r"nning man on the toolbar and li -. #hi% i% an exe "te ommand that r"n% the print pro ed"re. 'ne thing to be aware o0 i% that SAS by de0a"lt will read only "p to eight hara ter 1al"e%. Some name% longer than eight hara ter% will get "t o00 at the eighth letter or hara ter. #hi% problem i% ea%ily handled by %pe i0ying the n"mber o0 hara ter% that %ho"ld be allotted to a ommodate the length o0 the longe%t ob%er1ation being entered. 7or example5 a%%"me that yo" wo"ld li-e to read in the 0ollowing data %et6
Jay Smith Mary Carr Joe Jones "a#hel $onely ; 125 22 115 20 177 ! 105 27

&ow we ha1e two problem% that m"%t be addre%%ed. #he 0ir%t i% that the %"b;e t%< name% are more than eight hara ter% in length. #he other i% that there are %pa e% between the 0ir%t and la%t name% o0 ea h o0 the %"b;e t%. #hi% i% a problem be a"%e SAS "%e% a %pa e a% a delimiter. ,hen SAS en o"nter% the %pa e between the name%5 it a%%"me% that the next 1ariable i% being addre%%ed whi h i% not the a%e in o"r example. #he 0ollowing inp"t %tatement orre t% o"r problem.
input Sub_name $ 1%13 weight age;

8y %pe i0ying the n"mber o0 %pa e% needed to a ommodate the longe%t name5 o"r problem i% %ol1ed. Spe i0ying the n"mber o0 %pa e% needed to read in data an be "%ed 0or both hara ter and n"meri data a% 0ollow%6
input patient $ 1%13 weight 15%17 age 19%20;

&ow try exe "ting the 0ollowing %tatement%6

data one; input patient $ datalines; Jay Smith 125 Mary Carr 115 Joe Jones 177 "a#hel $onely 105 ; proc print; run;

1%13 weight 15%17 age 19%20; 22 20 ! 27

#hi% i% the o"tp"t yo" %ho"ld ha1e obtained6


&he S'S System (bs 1 2 ) Sub_name Jay Smith Mary Carr Joe Jones "a#hel $onely weight 125 115 177 105 age 22 20 ! 27

&ow let<% explore %ome other way% o0 bringing in data. A%%"me that the %ame in0ormation i% %a1ed a% a text 0ile5 ?example.txt@5 in ASC99 0ormat in the 0ollowing lo ation ?C6B#emp@ on yo"r CC. #hi% data %et an be read "%ing an ASC99 editor li-e notepad. #he 0ollowing i% a opy o0 the ontent% %tored in the 0ile ?example.txt@6 Jay Smith Mary Carr Joe Jones "a#hel $onely 125 22 115 20 177 ! 105 27

9n%tead o0 opying and pa%ting thi% in0ormation 0rom notepad to SAS5 the data %tored in ?example.txt@ an be bro"ght in "%ing the 0ollowing %et o0 %tatement%6
data one; in*ile +C,-&emp-e.ample/t.t+; input patient $ 1%13 weight 15%17 age 19%20; proc print; run;

#he in0ile %tatement gi1e% SAS the lo ation o0 text 0ile where the data o0 intere%t in %tored. &oti e that the %ame inp"t %tatement i% "%ed a% i0 the data were -eyp"n hed dire tly into SAS. &ow5 a%%"me that the %ame in0ormation i% %tored a% an EDCE* 0ile5 example.xl%5 in the 0ollowing lo ation ?C6B#emp@ on yo"r CC. Altho"gh EDCE* i% a good %pread%heet

program5 it i% not 1ery a ommodating i0 omplex analy%i% o0 yo" data i% re!"ired. #here0ore importing yo"r data 0rom EDCE* into SAS i% o0ten ne e%%ary5 and an be done ea%ily with the 0ollowing pro ed"re %tatement%6
proc import data*ile 0 +C,-&emp-e.ample/.ls+ out 0 e.data1 repla#e; proc print; run;

#he %tatement pro import allow% the SAS "%er to import data 0rom an EDCE* %pread%heet into SAS. #he data0ile %tatement pro1ide% the re0eren e lo ation o0 the 0ile. 9n thi% a%e5 the 0ile ?example@ with the exten%ion ?.xl%@ to denote an EDCE* 0ile i% the 0ile we wo"ld li-e to import. #he o"t %tatement i% "%ed to name the SAS data %et that ha% been reated by the import pro ed"re. &oti e that print pro ed"re ha% been "tili>ed on e more in order to 1iew the ontent% o0 the SAS data %et exdata1. Altho"gh we ha1e mentioned hara ter and n"meri data type%5 we ha1e yet to di% "%% 0ormatting n"meri data5 and how to wor- with 1ariable% that ha1e date% a% ob%er1ation%. *oo-ing at the 0ollowing data %et may help "% "nder%tand the ne e%%ary %tep% in1ol1ed when wor-ing with date% a% ob%er1ation% and 0ormatting n"meri data. #he ol"mn% in thi% data re0er% to the name o0 the %"b;e t5 the date they were ob%er1ed5 their date o0 birth5 and their weight in po"nd%5 whi h i% to on%i%t o0 two digit% behind a de imal point.
Mary Joe James 1111212002 0!105172 125!7 0511 12001 071021!7 15!) 0110312002 021221! 1!730

9n thi% a%e the re%ear her wo"ld li-e to reate a SAS data %et "%ing thi% in0ormation. *ater5 the re%ear her wo"ld li-e to "tili>e the in0ormation on%i%ting o0 the date o0 ob%er1ation and the date o0 birth to a !"ire the age o0 ea h %"b;e t. #he re%ear her al%o noti e% that the de imal point in the data 0or the weight o0 the %"b;e t% i% mi%%ing. Altho"gh the%e problem% may %eem omplex to the no1i e SAS "%er5 they an ea%ily be remedied with the "%e o0 ?in0ormat@ %tatement%. 9n0ormat %tatement% allow the "%er to %pe i0y the 0ormat o0 the 1ariable% at the inp"t %tage o0 the SAS ode. #hi% ba%i ally let% SAS -now what type o0 data it i% reading in be0ore it e1en read% it in. #he 0ollowing i% an inp"t %tatement that ontain% in0ormat% and other %ymbol% that we ha1e yet to di% "%%6
input sub $ 1%5 48 obs_date MM556610/ 419 dob MM55662/ 428 weight d5/2;

#he in0ormat ?MMDDAA10.@ i% ommonly "%ed when reading in date%. &oti e that the n"mber o0 hara ter% 0or the date o0 ob%er1ation i% ten5 eight n"meri 1al"e% and the two 0orward %la%he%. 7or the date o0 birth5 there are eight hara ter%5 %ix n"meri and the two 0orward %la%he%. #he 1ariable weight "%e% the in0ormat ?dE.2@ whi h in0orm% SAS to read in 0i1e 1al"e% with two behind a de imal point. Something el%e that %ho"ld loodi00erent i% the ?F@ 0ollowed by a n"mber in 0ront o0 the 1ariable name%. #he ?F@ indi ate% to SAS where to begin reading the 1ariable ob%er1ation% that are being inp"tted. 7or example ?FG@5 re0er% to hara ter ol"mn G5 %o SAS will begin reading ?ob%:date@ data at ol"mn eight. At thi% point5 we are ready to reate a data %etH let<% all it te%ting5 and it %ho"ld loo%omething li-e the 0ollowing6
data testing; input sub $ 1%5 d5/2; datalines; Mary 1111212002 Joe 0511 12001 James 0110312002 ; proc print; run;

48 obs_date MM556610/ 419 dob MM55662/ 428 weight 0!105172 125!7 071021!7 15!) 021221! 1!730

A0ter r"nning thi% ode5 yo" %ho"ld obtain the 0ollowing o"tp"t6
&he S'S System (bs 1 2 ) sub Mary Joe James obs_date 15!5! 15103 15) 3 dob !7)0 27 5 1513 weight 125/!7 15!/) 1!7/30

'ne thing that %ho"ld be readily noti eable i% that n"meri 1al"e% are gi1en in pla e o0 the date%. #ho%e n"meri 1al"e% repre%ent the n"mber o0 day% a0ter Ian"ary 15 1JK05 whi h i% the year "to00 0or SAS. Al%o note that the weight o0 the %"b;e t% i% in the de%ired 0ormat. #he al "lation o0 the age 0or ea h %"b;e t i% now relati1ely ea%y. 8y adding one line to the pre1io"% SAS ode5 we an %"btra t the ob%er1ation date 0rom the date o0 birth and di1ide by )KE.2E. 9 "%e )KE.2E be a"%e it ta-e% into a o"nt the 0a t that e1ery 0o"r year% i% a leap year. #he re%"lt% we de%ire %ho"ld be pro1ided with the 0ollowing SAS ode6
data testing;

input sub $ 1%5 d5/2; age 0 7obs_date % datalines; Mary 1111212002 Joe 0511 12001 James 0110312002 ; proc print; run;

48 obs_date MM556610/ 419 dob81365.25; 0!105172 125!7 071021!7 15!) 021221! 1!730

dob MM55662/ 428 weight

&oti e that the line ontaining age i% the only di00eren e between thi% pie e o0 SAS ode and the one pre1io"%ly written. #he 0ollowing i% the o"tp"t that %ho"ld ha1e been obtained6
&he S'S System obs_date dob 15!5! 15103 15) 3 !7)0 27 5 1513

(bs 1 2 )

sub Mary Joe James

weight 125/!7 15!/) 1!7/30

age 2 / )21 ))/2502 )7/2! 5

1.2 #ore on $ata #anagement b% &'ample #he 0ollowing t"torial allow% yo" to go thro"gh %ome %tep% that will help yo" get better a !"ainted with data management "%ing SAS. 7ir%t lo ate the 0ile ?anthro%.txt@ on the di%-ette pro1ided or on yo"r hard dri1e. #he 0ile %ho"ld ontain the 0ollowing line% o0 text6
&he *ollowing is a list o* *i9e indi9iduals along with their #orresponding height in in#hes and weight in pounds/ :ru#e :ur;s Janie Johnson Joe Ja#obs Jim $ewis $inda Carol !! !2 72 70 !0 122 1)5 157 12! 113

#here are !"ite a 0ew thing% to on%ider be0ore reading in thi% raw data. #he 0ir%t thing that yo" %ho"ld noti e i% that the 0ir%t two line% gi1e yo" in0ormation abo"t yo"r data %et. #he third line i% a blan- line5 and the data o0 intere%t %tart% on the 0o"rth line. 2n0ort"nately5 SAS annot di%ting"i%h between text that i% gi1ing in0ormation abo"t the data and the data it%el0H howe1er5 thi% dilemma an ea%ily be re%ol1ed in the 0ollowing manner6
data anthro; in*ile +C,-&emp-anthros/t.t+ *irstobs 0 4; input <ame $ 1%13 =eight 15%16 >eight 18%20;

Lere the data %et that wa% reated wa% named bmi. &ext we "%ed an 9&79*E %tatement to bring in the raw data 0rom either a di%-ette or o"r hard dri1e. &oti e the option in the 9&79*E %tatement ?0ir%tob%@. #he ?0ir%tob%@ option in the 9&79*E %tatement ba%i ally alert% SAS to the 0a t that the data that %ho"ld be read begin% on the ?nth@ line. 9n o"r example5 the nth line i% the 0o"rth line5 where ?n@ i% re%tri ted to the po%iti1e integer%. #he ?0ir%tob%@ option i% extremely "%e0"l e%pe ially when yo" a !"ire data %et% that ha1e extraneo"% in0ormation and want to ;"mp dire tly into the analy%i% pha%e. 7or the %a-e o0 ompletene%%5 let<% ta-e another example. #he 0ollowing text 0ile ontain% the exa t %ame in0ormation a% pre1io"%ly gi1en the only di00eren e i% that it<% arranged di00erently.
:ru#e :ur;s Janie Johnson Joe Ja#obs Jim $ewis $inda Carol !! !2 72 70 !0 122 1)5 157 12! 113

&his is a list o* *i9e indi9iduals along with their #orresponding height in in#hes and weight in pounds/

Lere the 0ir%t line ontain% the data we are intere%ted inH howe1er5 i0 we try to ?in0ile@ thi% data into SAS5 the problem o "r% in the la%t two line%. ,itho"t %pe i0ying where SAS %ho"ld %top reading the data5 SAS will treat all the line% a% i0 they were data that yo" wo"ld li-e read. ,e an ta-e are o0 thi% problem witho"t modi0y the text 0ile by "%ing the 0ollowing ommand line%6
data anthro; in*ile +C,-&emp-anthros/t.t+ obs 0 5; input <ame $ 1%13 =eight 15%16 >eight 18%20;

9n thi% a%e we are "%ing the ?ob%@ option5 whi h alert% SAS to %top 0rom reading any more line% o0 data a0ter the nth line ha% been read. 9n o"r example5 we want SAS to %top reading data a0ter the 0i0th line ha% been read. Ao" an ea%ily 1iew the ontent% o0 what SAS ha% read in by "%ing the ?pro print@ ommand 0ollowed by a ?r"n@ ommand. #he blo - o0 ode %ho"ld loo- li-e the 0ollowing6
data anthro; in*ile +C,-&emp-anthros/t.t+ obs 0 5; input <ame $ 1%13 =eight 15%16 >eight 18%20; proc print; run;

9n order to appre iate the %igni0i an e o0 what ha% been learned %o 0ar5 let<% extend o"r example into one that i% a bit more omplex. *et<% a%%"me that the %ame re%ear her ha% a%%igned two employee% into the 0ield in order to gather more data on the anthropometri % o0 the indi1id"al% eating at 0a%t 0ood re%ta"rant%. #he 0ir%t employee ret"rn% with the 0ollowing data %et %tored in the text 0ile ?anthro%1.txt@6
? went to the *ollowing pla#es, :urger@ingA M#5onaldsA and BiCCa =ut/ ? randomly #hose *i9e indi9iduals and #olle#ted their nameA height in in#hesA and weight in pounds/ &hese are my results, :rian $ong Jim :randa :renda Dreen Jo $ing 5aren >oods 72 !3 53 !2 !2 202 200 157 112 15!

#he re%ear her5 a0ter opening the 0ile5 -now% that the 0ollowing SAS ode i% needed in order to read in the data6
data one; in*ile +C,-&emp-anthros1/t.t+ *irstobs 0 5; input <ame $ 1%12 =eight 14%15 >eight 17%19;

&ow the %e ond employee arri1e% and gi1e% the re%ear her hi% data %et named ?anthro%2.txt@ ontaining the 0ollowing in0ormation6
Jim Ja#obs >endall $ee Bat Jones <el =enry Jeremy Ja#;s !3 70 !0 7) !7 1!5 220 1 ) 210 122 Ei9e indi9iduals were #hosen at

? went to >endy+s and Ja#;%in%the%:o./ random/

Again5 the re%ear her5 a0ter opening the 0ile5 -now% that the 0ollowing SAS ode i% needed in order to read the data in6
data two; in*ile +C,-&emp-anthros2/t.t+ obs 0 5; input <ame $ 1%12 =eight 14%15 >eight 17%19;

&ow that the re%ear her ha% the%e two data %et%5 %he wo"ld li-e to bring them together to 0orm one big data %et. #hi% i% alled on atenation and SAS i% apable o0 on atenating data %et% pro1ided the 1ariable name% and ontent oin ide among data %et%. #he 0ollowing ode ill"%trate% how thi% i% done6
data one; in*ile +C,-&emp-anthros1/t.t+ *irstobs 0 5; input <ame $ 1%12 =eight 14%15 >eight 17%19; run; data two; in*ile +C,-&emp-anthros2/t.t+ obs 0 5; input <ame $ 1%12 =eight 14%15 >eight 17%19; run; data three; set one two; proc print; run;

#he ?%et@ ommand i% riti al here be a"%e it allow% yo" to %et data %et% one and two into a third data %et alled three. #he re%"lt% an be %een in the o"tp"t a0ter r"nning ?pro print@6
&he S'S System (bs 1 <ame :rian $ong =eight 72 >eight 202

2 ) 5 ! 7 2 3 10

Jim :randa :renda Dreen Jo $ing 5aren >oods Jim Ja#obs >endall $ee Bat Jones <el =enry Jeremy Ja#;s

!3 53 !2 !2 !3 70 !0 7) !7

200 157 112 15! 1!5 220 1 ) 210 122

7inally5 we will end thi% di% "%%ion with merging data %et%. *et<% a%%"me that a third employee hired by the re%ear her had a ompanied the other two employee% and re orded the age% o0 the indi1id"al% who were inter1iewed. Lowe1er5 thi% in0ormation wa% not p"t into data %et three5 the pre1io"% data %et that wa% 0ormed. 7ir%t5 let<% loo- at the ontent% o0 the text 0ile named ?age%.txt@ %"bmitted by the third employee6
:rian $ong Jim :randa :renda Dreen Jo $ing 5aren >oods Jim Ja#obs >endall $ee Bat Jones <el =enry Jeremy Ja#;s 2) ! 51 20 )) 7 55 22 13

Sin e the goal i% to merge data %et three with data %et age%5 the merge an be a ompli%hed b"t a ?by 1ariable@ m"%t be %pe i0ied. #he ?by 1ariable@ i% "%"ally in0ormation on ob%er1ation% that i% ommon to both data %et%. 9n thi% a%e5 the only hoi e 0or a ?by 1ariable@ wo"ld be the 1ariable ?&ame@5 %in e the name% are gi1en in both %et% o0 data. 8e0ore we pro eed5 it %ho"ld be mentioned that the data %et% m"%t be %orted by the ?by 1ariable@5 in thi% a%e ?&ame@5 prior to the merge. #he 0ollowing ommand line% ill"%trate thi% pro ed"re6
data one; in*ile +C,-&emp-anthros1/t.t+ *irstobs 0 5; input <ame $ 1%12 =eight 14%15 >eight 17%19; run; data two; in*ile +C,-&emp-anthros2/t.t+ obs 0 5; input <ame $ 1%12 =eight 14%15 >eight 17%19; run; data three; set one two; proc sort; by <ame; run; data *our; in*ile +C,-&emp-ages/t.t+; input <ame $ 1%12 'ge 14%15;

proc sort; by <ame; proc; run; data *i9e; merge three *our; by <ame; proc print; run;

90 yo" will noti e5 the data %et% o0 intere%t are three and 0o"r %in e they ontain the in0ormation that we wo"ld li-e merged. #he pre1io"% two data %et%5 data %et% one and two5 were al%o in l"ded 0or ompletene%% %in e they were "tili>ed in the reation o0 data %et three. A0ter r"nning thi% pro ed"re5 the o"tp"t obtained %ho"ld appear a% 0ollow%6
&he S'S System (bs 1 2 ) 5 ! 7 2 3 10 <ame :renda Dreen :rian $ong 5aren >oods Jeremy Ja#;s Jim :randa Jim Ja#obs Jo $ing <el =enry Bat Jones >endall $ee =eight 53 72 !2 !7 !3 !3 !2 7) !0 70 >eight 157 202 15! 122 200 1!5 112 210 1 ) 220 'ge 51 2) )) ! 7 20 13 22 55

&oti e that the la%t ol"mn ontain% the in0ormation on the age% o0 ea h o0 the indi1id"al% ob%er1ed.

Section 2

Parametric Tests

2.1

Getting !c()ainted *it t e T+test

#hi% t"torial will introd" e yo" to t$te%t%5 A&'(A 3Analy%i% o0 (arian e45 and ba%i linear regre%%ion. *et<% begin with a t$te%t. 'ne ommon appli ation o0 the t$te%t i% to te%t whether the mean% o0 two di00erent 1ariable%5 mea%"red o1er the %ame %et o0 ob%er1ation%5 ha1e a %igni0i ant di00eren e. #hi% i% ba%i ally the %ame thing a% %aying doe% the mean o0 the di00eren e between the two 1ariable% o0 intere%t5 o1er the %ame %et o0 ob%er1ation%5 di00er %igni0i antly 0rom >ero. #hi% an be%t be ill"%trated 1ia an example. #a-e 0or in%tan e the data olle ted on indi1id"al<% height% and weight% 0rom di00erent 0a%t 0ood re%ta"rant%. #he 0ollowing in0ormation ome% 0rom the 0ir%t employee6
:rian $ong Jim :randa :renda Dreen Jo $ing 5aren >oods 72 !3 53 !2 !2 202 200 157 112 15!

And the next pie e o0 in0ormation ome% 0rom the %e ond employee6
Jim Ja#obs >endall $ee Bat Jones <el =enry Jeremy Ja#;s !3 70 !0 7) !7 1!5 220 1 ) 210 122

*et<% a%%"me that we ha1e read the t"torial on data %et management5 or ha1e %ome 0amiliarity with SAS already. ,e "%e o"r te hni!"e% to on atenate the two data %et% and obtain the 0ollowing data %et6
:rian $ong Jim :randa :renda Dreen Jo $ing 5aren >oods Jim Ja#obs >endall $ee Bat Jones <el =enry Jeremy Ja#;s 72 !3 53 !2 !2 !3 70 !0 7) !7 202 200 157 112 15! 1!5 220 1 ) 210 122

&ow we wo"ld li-e to di%ting"i%h between the two gro"p%. 'ne way to do thi% i% by adding another 1ariable alled Gro"p. Gro"p an be labeled ?1@ 0or the 0ir%t %et o0 0i1e ob%er1ation% and ?2@ 0or the %e ond %et.

8e0ore we ontin"e we %ho"ld %a1e the in0ormation we ha1e a% text in a temporary 0ile in o"r C$dri1e with the name ?onette%t@. #he ?.txt@ i% implied %o when %a1ing yo" %ho"ldn<t ha1e to add it on. &ow5 the 0ollowing SAS %tatement% an be "%ed to reate the data %et ?tte%ting@6
data ttesting; in*ile +C,-&emp-onettest/t.t+; input <ame $ 1%12 =eight 14%15 >eight 17%19 Droup 21%21;

*et<% a%%"me that the re%ear her wo"ld li-e to %ee i0 there i% a %igni0i ant di00eren e in the mean weight o0 indi1id"al% inter1iewed 0rom ea h o0 the re%ta"rant% by hi% employee%. #he 0ollowing ommand% an be "%ed to r"n a t$te%t6
proc ttest; #lass Droup; 9ar >eight; run;

#he ? la%%@ ommand ontain% the 1ariable that we are "%ing to di%ting"i%h between the two gro"p% o0 ob%er1ation% olle ted by ea h employee. Sin e we are intere%ted in omparing the weight% o0 the two gro"p%5 we "%e the ?1ar@ ommand with the %pe i0ied 1ariable o0 intere%t. 9n thi% a%e5 the 1ariable ?,eight@ a% %hown abo1e. 'ne more thing that %ho"ld be noted i% that altho"gh we ha1e the %ame n"mber o0 indi1id"al ob%er1ation 0or ea h gro"p thi% i% not a paired t$te%t. Ao" %ho"ld r"n a pair t$te%t only when there i% %ome logi al rea%oning 0or pairing the 1ariable% o0 intere%t. 'ne a%e when pairing i% re!"ired i% when one ob%er1ation i% dependent on another ob%er1ation in order to obtain the orre t in0ormation de%ired. 7or example5 A%%"me yo" ha1e a gro"p o0 %t"dent and that yo" gi1e them a pre$te%t at the beginning o0 the %eme%ter and a po%t$te%t at the end. &ow5 yo" are intere%ted to %ee i0 the o"r%e in rea%ed their -nowledge. #he be%t way to do thi% i% to pair the po%t$te%t to the pre$te%t o0 ea h %t"dent5 and examine the di00eren e in hi% or her % ore%. An example will be gi1en later to demon%trate the detail%. &ow getting ba - to o"r example5 we wo"ld li-e to %ee what -ind o0 o"tp"t SAS will pro1ide "% with. #here0ore a0ter r"nning the pre1io"% ommand% we a !"ire the 0ollowing re%"lt%6
&he S'S System &he &&FS& Bro#edure Statisti#s Hariable >eight >eight >eight Class 1 2 < 5 5 $ower C$ Mean 112/ 5 1 /!5 %!3/05 Mean 1!!/! 12 %17/ Gpper C$ Mean 21 /75 22)/)5 ) /2 3 $ower C$ Std 5e9 2)/2) 12/323 2)/321 Std 5e9 )2/773 )1/!3 )5/ 1 Gpper C$ Std 5e9 111/ ) 31/07 !7/2 5 Std Frr 17/) 2 1 /17 22/)32

5i** 71%28

&%&ests

Hariable >eight >eight

Method Booled Satterthwaite

Harian#es FKual GneKual

5E 2 7/7

t Halue %0/72 %0/72

Br I JtJ 0/ 53! 0/ !05

FKuality o* Harian#es Hariable >eight Method Eolded E <um 5E 5en 5E E Halue 1/50 Br I E 0/705

'ne o0 the problem% that mo%t indi1id"al% omplain abo"t when "%ing SAS i% that it gi1e% too m" h o"tp"t5 or o"tp"t that mo%t indi1id"al% 0ind extraneo"%. Altho"gh thi% i% tr"e mo%t o0 the time5 the o"tp"t di%played here i% 1ery "%e0"l. Lowe1er5 we are intere%ted in the ,eight Di005 whi h i% the di00eren e in the mean% o0 the two weight%. ,e wo"ld li-e to -now i0 the di00eren e i% %igni0i antly di00erent 0rom >ero. 2nder the n"ll hypothe%i%5 we are a%%"ming no %igni0i ant di00eren e. Al%o5 noti e that SAS pro1ide% the %tati%ti % 0or the a%%"mption o0 e!"ality o0 1arian e. 9n thi% a%e with a p$ 1al"e o0 0.70E/5 we annot re;e t the n"ll hypothe%i% that the 1arian e% 0or the two gro"p% are e!"al. &ow5 ob%er1ing the t$te%t with the pooled method5 we obtain a p$1al"e o0 0./EJK and th"% annot re;e t the n"ll hypothe%i% o0 no di00eren e between the mean weight% o0 the two gro"p%. 'ne more thing that %ho"ld be mentioned i% that the hypothe%i% te%t we ond" ted wa% a two$tailed te%t. 8a%i ally what thi% mean% i% that we began with the n"ll hypothe%i% o0 the mean di00eren e being e!"al to >ero5 and the alternati1e hypothe%i% that the mean di00eren e i% not e!"al to >ero. Sin e no dire tionality i% implied meaning that one gro"p i% not expe ted to ha1e a higher mean than the other5 we re0er to o"r te%t a% a two$tailed te%t rather than a one$tailed te%t. &ow let<% explore another % enario. #he next data %et wa% 0ormed a0ter the indi1id"al% who were inter1iewed regarding their height and weight were expo%ed to a %ix$wee- diet inter1ention. #heir weight% were re orded prior to the %ix$wee- period5 and a0ter they ompleted the inter1ention. #he 0ollowing i% a opy o0 the data %et a0ter thi% in0ormation wa% olle ted6
:rian $ong Jim :randa :renda Dreen Jo $ing 5aren >oods Jim Ja#obs >endall $ee Bat Jones <el =enry Jeremy Ja#;s 72 !3 53 !2 !2 !3 70 !0 7) !7 202 200 157 112 15! 1!5 220 1 ) 210 122 200 132 1!0 110 150 1!2 213 1 0 20 12)

&ow the re%ear her i% intere%ted to %ee i0 the inter1ention may ha1e had an impa t on the weight o0 the indi1id"al%. #he 0ollowing SAS ode an be "%ed to r"n a paired t$te%t in order to a !"ire the de%ired in0ormation6
data ttesting; in*ile +C,-&emp-pairttest/t.t+; input <ame $ 1%12 =eight 14%15 >eight1 17%19 >eight2 21%23;

proc ttest; paired >eight1L>eight2; run;

#he orre%ponding o"tp"t loo-% li-e the 0ollowing6


&he S'S System &he &&FS& Bro#edure Statisti#s 5i**eren#e >eight1 % >eight2 < 10 $ower C$ Mean %0/!07 Mean 2/1 Gpper C$ Mean /2072 $ower C$ Std 5e9 2/!0)1 Std 5e9 )/72 5 Gpper C$ Std 5e9 !/303 Std Frr 1/13!2

&%&ests 5i**eren#e >eight1 % >eight2 5E 3 t Halue 1/75 Br I JtJ 0/11)2

&oti e here that on e again we annot re;e t the n"ll hypothe%i%5 and m"%t on l"de that the inter1ention had no %igni0i ant impa t on weight.

2.2 !N,-! b% &'ample &ext5 we loo- at example demon%trating the "%e o0 A&'(A. *et<% a%%"me that the re%ear her ha% data on indi1id"al% 0rom three di00erent diet amp%. All the re%ear her i% on erned with i% %eeing whether the mean weight% o0 the indi1id"al% in ea h amp are %igni0i antly di00erent 0rom one another. Sin e we are omparing three di00erent mean%5 we m"%t employ the "%e o0 A&'(A. #he pro eeding line% repre%ent the SAS ode and data 0or thi% example.
data e.pano9a; input group weight; datalines; 1 22) 1 2) 1 25 1 2!7 1 2) 2 227 2 21) 2 215 2 2) 2 25! ) 2) ) ) 2 ) 132 ) 25! ) )0) ; proc anova; #lass group; model weight 0 group; means group; run;

#he 0ollowing i% the orre%ponding o"tp"t to the pre1io"% line% o0 ode.


&he S'S System &he '<(H' Bro#edure 5ependent Hariable, weight Sour#e Model Frror Corre#ted &otal Sour#e group Sum o* 5E SKuares Mean SKuare E Halue 2 2071/!0000 10)5/20000 0/!3 12 17332/ 0000 1 33/2!!!7 1 20070/00000 Coe** Har "oot MSF weight Mean 15/ 312 )2/72211 250/0000 5E 'no9a SS Mean SKuare E Halue 2 2071/!00000 10)5/200000 0/!3 Br I E 0/5201

"%SKuare 0/10)213

Br I E 0/5201

Lere we %ee that be a"%e the model i% not %igni0i ant 3p$1al"e M 0.E20145 we m"%t on l"de that the mean weight% o0 the three gro"p% are not %igni0i antly di00erent.

2.3 Linear Regression b% &'ample 7inally5 let<% end o"r di% "%%ion with ba%i linear regre%%ion. #he re%ear her ha% in0ormation on the di%tan e indi1id"al% li1e 0rom 0a%t$0ood pla e% and the n"mber o0 time% they eat at tho%e pla e% per wee-. #he re%ear her want% to %ee i0 there i% a relation%hip between the%e to 1ariable% in order to a%%e%% i0 lo ation o0 re%iden e i% a good predi tor o0 the n"mber o0 time% indi1id"al% eat at 0a%t$0ood pla e% per wee-. #he 0ollowing i% a 1iew o0 the raw data %a1ed a% ?reg.txt@ in a #emp 0ile on the C$dri1e. #he 0ir%t ol"mn repre%ent% the n"mber o0 mile% 0rom the 0a%t$0ood pla e 3mile%4 and the %e ond ol"mn i% the n"mber o0 time% per wee- the indi1id"al eat% at the 0a%t$0ood pla e 3eat:time%4. &ext5 yo" will %ee the SAS ode "%ed to a e%% the data and r"n the linear regre%%ion.
0/) 1/2) !/72 5/5 0/ ) 1/12 2/) 0/32 )/) 1/20 5 ) 1 1 2 2

data *ast*ood; in*ile +C,-&emp-reg/t.t+; input miles eat_times; proc reg; model eat_times 0 miles; plot eat_timesLmiles;

r"n. 7inally5 the SAS o"tp"t i% %hown with a plot o0 the data.
&he S'S System &he "FD Bro#edure Model, M(5F$1 5ependent Hariable, eat_times 'nalysis o* Harian#e Sour#e Model Frror Corre#ted &otal 5E 1 2 3 Sum o* SKuares 15/07 )5 2/325!5 12/00000 0/!0 7 )/00000 20/15722 Mean SKuare 15/07 )5 0/)!571 E Halue 1/22 Br I E 0/0002

"oot MSF 5ependent Mean Coe** Har

"%SKuare 'dM "%SK

0/2)75 0/2171

Barameter Fstimates Hariable ?nter#ept miles 5E 1 1 Barameter Fstimate /)!22) %0/52)15 Standard Frror 0/225! 0/0302) t Halue 15/27 %!/ 2 Br I JtJ N/0001 0/0002

9n thi% example the n"mber o0 time% indi1id"al% ate at the 0a%t$0ood pla e% de rea%ed with the n"mber o0 mile% they li1e 0rom the 0a%t$0ood pla e. #he model i% %igni0i ant with a p$ 1al"e M 0.0002 and the relation%hip i% %trong %in e +$%!"ared M 0.G)7E.

Section 3

NonParametric Tests

3.1 Wilco'on Ran/ S)m Test and 0r)s/al+Wallis Test b% &'ample #hi% i% a t"torial on nonparametri te%t%. #he bigge%t di00eren e between a parametri and nonparametri te%t i% the 0a t that a parametri te%t a%%"me% that the data "nder in1e%tigation i% oming 0rom a normal di%trib"tion. #he SAS %o0tware pro1ide% %e1eral nonparametri te%t% %" h a% the ,il oxon ran-$%"m te%t5 whi h i% e!"i1alent to the Mann$ ,hitney te%t 0or two %ample%5 and the .r"%-al$,alli% te%t when dealing with two or more %ample%. Con%ider the 0ollowing example5 +e%ear her 8ob i% intere%ted in te%ting the di00eren e between the e00e ti1ene%% o0 two allergy dr"g% o"t on the mar-et. Le wo"ld li-e to admini%ter dr"g A to a random %ample o0 %t"dy %"b;e t% and then dr"g 8 to another random %ample who %"00er 0rom the %ame %ymptom% a% tho%e indi1id"al% ta-ing dr"g A. +e%ear her 8ob wo"ld li-e to %ee i0 there i% a di00eren e between the two gro"p% in the time5 in min"te%5 0or %"b;e t% to 0eel relie0 0rom their allergy %ymptom%. #able 1. #he time5 in min"te%5 "ntil relie0 i% 0elt a0ter dr"g ha% been admini%tered 0or %t"dy gro"p% A and 8. S)b1ect $r)g ! $r)g 2 1 /) 2G 2 /0 )) ) )2 /G / )7 )7 E EE /0 K E0 /2 7 E2 )E G )) /) 9n order to do %ome analy%i% the 0ir%t %tep wo"ld be to 0orm a SAS data %et a% 0ollow%6
data drugtest; input subMe#t drug_group $ time; datalines; 1 ' ) 2 ' 0 ) ' )2 ' )7 5 ' 55 ! ' 50 7 ' 52 2 ' )) 3 : 22 10 : )) 11 : 2 12 : )7 1) : 0 1 : 2 15 : )5 1! : )

; proc means median min ma.; by drug_group; 9ar time; proc npar1way wil#o.on; #lass drug_group; 9ar time; run;

9n order to per0orm the%e nonparametri te%t%5 we "%e the pro ed"re ?npar1way@ and the option ?wil oxon@ to re!"e%t that parti "lar te%t. &ote that ?wil oxon@ i% not the only option a1ailable. 'ther option% are ?median@5 ?mood@5 and ?exa t@5 b"t 0or o"r p"rpo%e% we will not di% "%% the%e option% at thi% time. 9n the a%e abo1e5 we ha1e demon%trated the ,il oxon +an- S"m #e%t in order to te%t i0 a %igni0i ant di00eren e exi%t% between the dr"g gro"p% in median time to relie0 0rom allergy %ymptom%. #he 0ollowing i% the o"tp"t obtained 0rom the SAS ode6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% drug_group0' 'nalysis Hariable , time Median Minimum Ma.imum OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 1/5000000 )2/0000000 55/0000000 OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% drug_group0: 'nalysis Hariable , time Median Minimum Ma.imum OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO )2/5000000 22/0000000 2/0000000 OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO &he <B'"1>'6 Bro#edure >il#o.on S#ores 7"an; Sums8 *or Hariable time Classi*ied by Hariable drug_group drug_ Sum o* F.pe#ted Std 5e9 Mean group < S#ores Gnder =0 Gnder =0 S#ore OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO ' 2 77/0 !2/0 3/ 3)252 3/!250 : 2 53/0 !2/0 3/ 3)252 7/)750 '9erage s#ores were used *or ties/ >il#o.on &wo%Sample &est Statisti# <ormal 'ppro.imation P One- ided !r " # $wo- ided !r " %#% t 'ppro.imation One- ided !r " # $wo- ided !r " %#% 77/0000 0/235) 0.1853 0.3706 0.1924 0.3848

P in#ludes a #ontinuity #orre#tion o* 0/5/ @rus;al%>allis &est Chi%SKuare 0/2327

5E !r " &'i- (uare

1 0.3431

#he 0ir%t thing that yo" %ho"ld noti e i% that %ome de% ripti1e %tati%ti % where gi1en prior to the te%t o0 median di00eren e%. #hi% i% mainly be a"%e pro ed"re ?npar1way@ di%play% the mean not the median 0or ea h dr"g gro"p. 7inally5 we are intere%ted in ob%er1ing the o"tp"t gi1en "nder the heading &ormal Approximation. #he probabilitie% gi1en are tho%e a%%o iated with the Mann$,hitney te%t. 8e a"%e o0 the way thi% hypotheti al problem i% pre%ented5 a two$tailed te%t %ho"ld be employed mainly be a"%e the dire tionality o0 the o"t ome i% not -nown 3yo" don<t -now whi h dr"g wor-% better4. 9n any a%e5 be a"%e the probabilitie% are abo1e 0.0E5 yo" annot re;e t the n"ll hypothe%i% and m"%t on l"de that there i% no di00eren e between the median time% to relie0 0or both dr"g gro"p%.

Section 4

Logistic Regression

4.1 Logistic Regression b% &'ample #he 0ollowing i% a t"torial on logi%ti regre%%ion. #here are %e1eral boo-% that di% "%% logi%ti regre%%ion in detail5 b"t 0or o"r p"rpo%e% we<ll ;"%t %-im the %"r0a e. *ogi%ti regre%%ion i% a power0"l toolH howe1er5 -nowing when to "%e it i% the mo%t important thing. 7"ndamentally5 it i% %aid that logi%ti regre%%ion an be "%ed when yo" ha1e an o"t ome 1ariable that i% di hotomo"%. Altho"gh that i% "%"ally the a%e5 it i%n<t the only time. Ao" an "%e logi%ti regre%%ion with poly hotomo"% and ordinal data al%o. 8e0ore we begin5 let<% di% "%% the linear regre%%ion model in order to gain a better "nder%tanding o0 the di00eren e% between linear and logi%ti regre%%ion. #he %tandard a%%"mption% o0 linear regre%%ion "%ing ordinary lea%t %!"are% are a% 0ollow%6 #he model ha% the 0orm6 yi M b0 N b1x N ei #he expe ted 1al"e o0 ei M 0 #he 1arian e o0 ei i% on%tant #he ei<% are independent and identi ally di%trib"ted a% a &ormal di%trib"tion

7or logi%ti regre%%ion5 the%e a%%"mption% hange in the 0ollowing manner6 #he expe ted 1al"e o0 ei M pi #he 1arian e o0 ei M pi31 $ pi4 #he ei<% are binomially di%trib"ted

9t i% riti al that we loo- at the%e a%%"mption% in order to get a better "nder%tanding o0 o"r analy%i%. &ow let<% begin with a %imple example in order to introd" e the topi in better detail. A%%"me that +e%ear her Smith ha% ond" ted a %t"dy in1ol1ing %"i ide and depre%%ion. +e%ear her Smith i% intere%ted in thi% relation%hip between %"i ide and depre%%ion be a"%e he wo"ld li-e to %how that indi1id"al% who are depre%%ed are more li-ely to attempt %"i ide. #he 0ollowing data wa% olle ted 1ia %"r1ey% 0rom a p%y hiatri ward in %malltown. &ote that ?1@ 0or depre%%ion indi ate% that the indi1id"al wa% on%idered lini ally depre%%ed be a"%e they % ored abo1e a ?E@ on a depre%%ion riteria % ale. A ?1@ 0or %"i ide indi ate% that the indi1id"al attempted %"i ide. Data on 20 indi1id"al% i% gi1en below.
SubMe#t Sui#ide 5epressionCriteria 5epression 1 1 0 2 0 2 0 ) 1 0 0 ) 0 5 0 ! 1 ! 0 2 1 7 1 0 2 0 2 0 3 0 2 0 10 0 ) 0 11 0 2 0

12 1) 1 15 1! 17 12 13 20

1 0 0 1 1 1 1 1 1

1 ! 7 3 7 2 3 2

0 0 1 1 1 1 1 1 1

Cro eed to 1iew yo"r data with the 0ollowing ommand%6


data sui#ide; in*ile +C,-&emp-sui#ide/t.t+ *irstobs 0 2; input subMe#t sui#ide dep#ritera depression; proc print; run;

'ne thing that an be done now i% a plot o0 the data. At the moment we will not be di% "%%ing graphi % "%ing SAS. #here0ore we will ontin"e the di% "%%ion in Ex el ;"%t to obtain a plot o0 the data and re%"me with SAS. 7or the moment5 we will a%%"me that yo" ha1e %ome experien e with Ex el and are apable o0 manip"lating a %pread%heet and ma-ing hart%. Cro eed by ma-ing a hart that plot% S"i ide 1% Depre%%ion. Ao"r plot %ho"ld loo- li-e the 0ollowing6

1.2 1 Attempted Suicide 0.8 0.6 0.4 0.2 0 0 2 4 6 8 10 Depression Scale

At thi% point5 it %ho"ld be relati1ely ea%y to %ee that a %traight line will not model thi% type o0 data 1ery well. Lowe1er5 an S$%haped "r1e or %igmoid "r1e wo"ld do the tri -. 7or that rea%on5 we wo"ld employ logi%ti regre%%ion. 9n order to ma-e o"r example ea%ier

we will on%ider the 1ariable% %"i ide and depre%%ion whi h are both hara teri>ed a% 1<% and 0<%. ,ith the 0ollowing SAS ode5 we an r"n a logi%ti regre%%ion a% 0ollow%6
data sui#ide; in*ile +C,-&emp-sui#ide/t.t+ *irstobs 0 2; input subMe#t sui#ide dep#riteria depression; proc )ogistic des#ending; model sui#ide 0 depression; run;

#he only thing that i% di00erent in thi% blo - o0 ode i% the ?pro logi%ti @ whi h initiate% the logi%ti pro ed"re. &oti e the option ?de% ending@ a0ter the pro ed"re %tatement. #hi% tell% SAS to "%e 1 a% the o"t ome o0 intere%t 0or the dependent 1ariable5 ?%"i ide@. A0ter the pro %tatement ome% the %tatement ontaining the model 0ormat5 yo" %ho"ld alway% p"t the dependent 1ariable 0ir%t5 an e!"al %ign5 and 0inally the independent 1ariable3%4. #he 0ollowing o"tp"t i% obtained on e the%e ommand% ha1e been exe "ted6
&he $(D?S&?C Bro#edure Model ?n*ormation 5ata Set "esponse Hariable <umber o* "esponse $e9els <umber o* (bser9ations $in; Eun#tion (ptimiCation &e#hniKue >("@/SG?C?5F sui#ide 2 20 $ogit Eisher+s s#oring

"esponse Bro*ile (rdered Halue 1 2 sui#ide 1 0 &otal EreKuen#y 10 10

Model Con9ergen#e Status Con9ergen#e #riterion 7DC(<H01F%28 satis*ied/ Model Eit Statisti#s ?nter#ept (nly 23/72! )0/722 27/72! ?nter#ept and Co9ariates 23/272 )1/2!3 25/272

Criterion '?C SC %2 $og $

&esting Dlobal <ull =ypothesis, :F&'00 &est $i;elihood "atio S#ore >ald Chi%SKuare 1/2 20 1/2122 1/757 5E 1 1 1 Br I ChiSK 0/17 0 0/1775 0/1250

'nalysis o* Ma.imum $i;elihood Fstimates Barameter ?nter#ept depression 5E 1 1 Fstimate %0/553! 1/252! Standard Frror 0/!2!2 0/3 3 Chi%SKuare 0/7371 1/757 Br I ChiSK 0/)720 0/1250

Odds *atio +stimates +..ect depression !oint +stimate 3.500 95, -a)d &on.idence /imits 0.549 22.300

'sso#iation o* Bredi#ted Brobabilities and (bser9ed "esponses Ber#ent Con#ordant Ber#ent 5is#ordant Ber#ent &ied Bairs 2/0 12/0 !/0 100 Somers+ 5 Damma &au%a # 0/)00 0/55! 0/152 0/!50

&ow that yo" ha1e had a han e to 1iew the o"tp"t pay %pe ial attention to the %e tion that i% in bold titled 'dd% +atio E%timate%. 7rom thi% in0ormation we get an e%timate 0or the '+ M ).E. 8a%i ally thi% tell% "% that indi1id"al% who attempted %"i ide are ).E time% more li-ely to be depre%%ed. Lowe1er5 yo" m"%t pay lo%e attention to the JEO Con0iden e 9nter1al o0 30.E/J5 22.)004 that a ompanie% the '+. 8e a"%e the JEO Con0iden e 9nter1al ontain% 1.0005 the e%timate 0or the '+ i% not %tati%ti ally %igni0i ant. &ow let<% ta-e the 0ollowing % enario. A%%"me that +e%ear her Smith belie1e% that +a e i% a -ey 0a tor in %"i ide attempt%5 and he wo"ld li-e to explore hi% hypothe%i% by loo-ing at data on %"i ide and depre%%ion oming 0rom ,hite%5 8la -%5 and Li%pani %. ,e will be "%ing the text 0ile P%"i ide2.txt<. Ao" %ho"ld ha1e been gi1en a di%-ette where thi% data i% %tored. #he re%ear her -now% that i% it ommon pra ti e to "%e ,hite% a% the re0eren e gro"p. 9n thi% example5 we wo"ld li-e to ompare 8la -% and Li%pani % to ,hite%5 b"t in order to do %o we need to reate d"mmy 1ariable%. #able 1 re0er% to how thi% i% to be done. #able1. ,hite% 3re04 8la -% Li%pani % d"mmy1 0 1 0 d"mmy2 0 0 1

At the moment5 thi% may %eem on0"%ingH howe1er5 the 0ollowing SAS ode %ho"ld gi1e yo" %ome in%ight when reating d"mmy 1ariable%6
data sui#ide2; in*ile +',-sui#ide2/t.t+ *irstobs 0 2; input Sui#ide 5epression "a#e; i* "a#e 0 2 then dummy1 0 1;

else dummy1 0 0; i* "a#e 0 3 then dummy2 0 1; else dummy2 0 0; proc )ogistic des#ending; model Sui#ide 0 dummy1 dummy2; run;

A0ter the program i% r"n5 the 0ollowing o"tp"t i% obtained6


&he $(D?S&?C Bro#edure Model ?n*ormation 5ata Set "esponse Hariable <umber o* "esponse $e9els <umber o* (bser9ations $in; Eun#tion (ptimiCation &e#hniKue >("@/SG?C?5F2 Sui#ide 2 105 $ogit Eisher+s s#oring

"esponse Bro*ile (rdered Halue 1 2 Sui#ide 1 0 &otal EreKuen#y 2 !)

Model Con9ergen#e Status Con9ergen#e #riterion 7DC(<H01F%28 satis*ied/ Model Eit Statisti#s ?nter#ept (nly 1 )/))2 1 5/32! 1 1/))2 ?nter#ept and Co9ariates 1 2/133 150/1!0 1)!/133

Criterion '?C SC %2 $og $

&esting Dlobal <ull =ypothesis, :F&'00 &est $i;elihood "atio S#ore >ald Chi%SKuare 5/1))3 5/0000 /2 )1 5E 2 2 2 Br I ChiSK 0/07!2 0/0221 0/0222

'nalysis o* Ma.imum $i;elihood Fstimates Barameter ?nter#ept dummy1 dummy2 5E 1 1 1 Fstimate %1/0!03 0/77)2 1/1120 Standard Frror 0/)2!7 0/51!0 0/51)2 Chi%SKuare 7/52 2/2 5 /7)57 Br I ChiSK 0/00!1 0/1) 0 0/0235

Odds *atio +stimates +..ect dummy1 dummy2 !oint +stimate 2.167 3.059 95, -a)d &on.idence /imits 0.788 1.117 5.957 8.373

'sso#iation o* Bredi#ted Brobabilities and (bser9ed "esponses

Ber#ent Con#ordant Ber#ent 5is#ordant Ber#ent &ied Bairs

!/0 22/2 )1/7 2! !

Somers+ 5 Damma &au%a #

0/2)2 0/) 3 0/115 0/!13

'n e again5 let<% loo- at the 'dd% +atio e%timate%. Sin e d"mmy1 re0er% to 8la -%5 we an on l"de that 8la -% are 2.1K7 time% more li-ely to attempt %"i ide ompared to ,hite%. Sin e d"mmy2 re0er% to Li%pani %5 we an on l"de that Li%pani % are ).0EJ time% more li-ely to attempt %"i ide ompared to ,hite%. &ote that the JEOCon0iden e 9nter1al i% %igni0i ant only 0or Li%pani % be a"%e it doe% not ontain 1.000.

You might also like