******************************************************************** * * * tuyns.do * * * * PURPOSE: read the cancer data * * * * DATE: 04/12/04 * * * ******************************************************************** infile age alc tob count1 count0 using http://courses.washington.edu/b513/datasets/tuyns.dat reshape long count, i(age alc tob) j(y) *** *** variable labels *** label variable age "Age Group" label variable alc "Alcohol" label variable tob "Tobacco" label variable y "Case/Control Status" label define agegps 1 "25-34" 2 "35-44" 3 "45-54" 4 "55-64" 5 "65-74" 6 "75+" label define alcgps 1 "<40g/day" 2 "40-79g/day" 3 "80-119g/day" 4 "120+g/day" label define tobgps 1 "0-9g/day" 2 "10-19g/day" 3 "20-29g/day" 4 "30+g/day" label define status 1 "Case" 0 "Control" label values age agegps label values alc alcgps label values tob tobgps label values y status generate newalc = 0 replace newalc = 1 if alc>=3 generate newtob =0 replace newtob = 1 if tob>=2 *** *** explore age and case-control status *** table y age [freq=count] tabodds y age [freq=count] tabodds y age [freq=count], or *** *** explore age and exposure status in the control group *** tab age newalc [freq = count] if y ==0, row tab age newtob [freq = count] if y ==0, row tab newalc newtob [freq = count] if y ==0 *** *** recode age *** generate newage=age recode newage 1/2=1 3=2 4=3 5=4 6=5 label define newgps 1 "25-44" 2 "45-54" 3 "55-64" 4 "65-74" 5 "75+" label values newage newgps *** *** explore age and case-control status *** tabodds y newage [freq=count] tabodds y newage [freq=count], or tabodds y newage [freq=count], or base(4)