/****************************** This exercise shows different data management techniques. Filename: exercise4.sas ********************************/ OPTIONS FORMCHAR="|----|+|---+=|-/\<>*"; title; options pageno=1; /*Question1: Assign a libname*/ libname mylib "C:\Users\kwelch\Desktop\epid759"; /*Question 2: Make a temporary dataset*/ data temp; set mylib.breastcancer2; run; /*Question 3: Make a subset with women in menopause*/ data menopause; set mylib.breastcancer2; if menopause=1; run; proc contents data=menopause varnum; run; /*Question 4: Make a subset with women born before Jan 1, 1940*/ data jan1940; set mylib.breastcancer2; if dob < "01JAN1940"d and dob not=.; run; /*Question 5: Make a Dataset with Fewer Variables*/ data fewvars; set mylib.breastcancer2; keep idnum stopmens agestop1 dob; run; /*Question 6: Sort the data*/ proc sort data=mylib.breastcancer2; by idnum; run; proc contents data=mylib.breastcancer2 varnum; run; /*Question 7: Sort the data by Stopmens and DOB*/ proc sort data=mylib.breastcancer2; by stopmens dob; run; /*Question 8: Descriptive Statistics by Stopmens*/ proc means data=mylib.breastcancer2; where stopmens not=.; by stopmens; run; /*Question 9: Get a printout of cases with DOB between Jan1, 1920 and January 1, 1930*/ proc print data=mylib.breastcancer2; where dob between "01JAN1920"d and "01JAN1930"d; *where (dob>='01JAN1920'D and dob<='01JAN1930'D); run; proc datasets lib=work; delete fewvars; run; delete jan1940; run; quit;