-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPH490KR_HW4
53 lines (40 loc) · 1.33 KB
/
PH490KR_HW4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*****************************
This program run the activities
for Homework 4, Spring 2018
Emily Lynch
April 1, 2018
*****************************/
*1. Assign libname to folder where dataset is stored;
libname ph490kr "C:\Users\emilylynch\Desktop\ph490kr";
*read in dataset;
data HW4;
set ph490kr.lowbwt;
run;
*2. Label each variable and its values;
proc format library=ph490kr;
value cntrl_case 0= "0_cntrlNorm" 1= "1_caseLow";
value raceL 0= "0_white" 1= "1_black" 2= "2_other";
value smkstat 0= "0_nonsmk" 1= "1_smk";
run;
options fmtsearch=(ph490kr);
data HW4;
set HW4;
format low cntrl_case. race raceL. smoke smkstat.;
label id= "id: participant ID num";
label low= "low: case/cntrl status for low birthwght baby";
label age= "age: moms age, yrs";
label race= "race: moms race";
label smoke= "smoke: moms smoke status";
label ftv= "ftv: num of Dr visits first tri";
label bwt= "bwt: baby birthwght, grams";
run;
proc contents data=HW4;
run;
*3. Create new variable grouping age into: <20, 20-24, 25-29, 30-34, >=35. Label new var and its values. Check work.;
if (age<20) then agecat=1;
else if (age>=20) & (age<24) then agecat=2;
else if (age>=25) & (age<29) then agecat=3;
else if (age>=30) & (age<34) then agecat=4;
else if (age>=35) then agecat=5;
else if age=. then agecat=.;
value