/*Exercise 3*/ options formchar="|----|+|---+=|-/\<>*"; options yearcutoff = 1900; data breastcancer; infile "C:\Users\kwelch\Desktop\epid759\brca.dat"; input IDNUM 1-4 stopmens 5 agestop1 6-7 numpreg1 8-9 agebirth 10-11 mamfreq4 12 @13 dob mmddyy8. education 21-22 totincome 23 smoker 24 weight 25-27; format dob mmddyy10.; if stopmens = 9 then stopmens = .; if agestop1 in(88,99) then agestop1 = .; /*if agestop1 = 88 or agestop1 = 99 then agestop1 = .;*/ if numpreg1 in (88,99) then numpreg1=.; if agebirth in (9,88,99) then agebirth=.; if mamfreq4 = 9 then mamfreq4=.; if dob = "09SEP1999"d then dob=.; if education = 99 then education=.; if totincome in (8,9) then totincome=.; if smoker=9 then smoker=.; if weight = 999 then weight=.; label education = "Education Level of Respondent"; label smoker = "Smoking Status"; run; /*************************************************** Exercise 3 starts here ****************************************************/ data breastcancer2; set breastcancer; /*First way to set up AGEBIRTHCAT*/ if agebirth not=. then do; if agebirth<20 then agebirthcat = 1; if agebirth >=20 and agebirth <=25 then agebirthcat=2; if agebirth >25 then agebirthcat=3; end; /*Second way to set up AGEBIRTHCAT*/ if agebirth >=0 and agebirth<20 then agebirthcat2 = 1; if agebirth >=20 and agebirth <=25 then agebirthcat2=2; if agebirth >25 then agebirthcat2=3; /*Set up EDCAT and dummy variables*/ if education not=. and education not=9 then do; if education < 4 then edcat=1; if education = 4 then edcat=2; if education > 4 then edcat=3; edcat1 = (edcat=1); edcat2 = (edcat=2); edcat3 = (edcat=3); end; /*Another way to set up an Education Category Variable*/ if education in(1,2,3) then newedcat=1; if education = 4 then newedcat=2; if education in(5,6,7,8) then newedcat=3; /*Set up dummy variables for EDCAT*/ if edcat = 1 then edcatdummy1 = 1; if edcat in (2,3) then edcatdummy1=0; if edcat = 2 then edcatdummy2 = 1; if edcat in (1,3) then edcatdummy2=0; if edcat = 3 then edcatdummy3 = 1; if edcat in (1,2) then edcatdummy3=0; if stopmens=1 then menopause=1; if stopmens=2 then menopause=0; menopause2 = 2-stopmens; run; proc means data=breastcancer2; run; libname mylib "C:\Users\kwelch\Desktop\epid759"; data mylib.breastcancer2; set work.breastcancer2; run; data mylib.breastcancer; set work.breastcancer; run; proc copy in=work out=mylib memtype=data; run;