/* Recode health variables to dummy variables: Self-reported health: srh (categorical, 1-5), shlt (binary 0 = E/VG/G, 1 = F/P Mortality: died SEE healtheasurex.xls FOR FULL LIST OF PSID HEALTH MEASURES To be consistent with HRS, eventually want to include: cancre, diabe, hearte, hibpe, lunge, stroke variables on ADL and IADL smoke now, smoke ever obese, overwt, underwt, BMI 1/30/13 - Recoding died based on death year and sequence number */ %include "setup.inc"; %include "&maclib.psidget.mac"; /* macro to get early release data */ %include "&maclib.renyrv.mac"; /* macro to rename variables */ %include "&maclib.recode_absorb.mac"; /* macro to recode 1,5,8,9 type variables with absorbing state (once 1, always 1) */ %include "&maclib.severity.mac"; /* macro to recode normal limitations from diseases */ %include "&maclib.onset.mac"; /* Macro to create onset dummy variables - takes condition and age as input, returns dummy variable */ %include "&maclib.recode_chroncond.mac"; /*macro to recode answers to chronic condition question, and determine age of onset. NB open-ended question -low prevalence -use at your own risk*/ data proj.health; set proj.extract_data (keep=id srh: died: inyr: diedyr: cancr: diab: heart: hibp: lung: strok: chron: smoken: smokev: wght: wghtkg: heightft: heightin: heightmt: seq: deathyr chldhlth: lgtexcfreq: lgtexcunit: hvyexcfreq: hvyexcunit: musclefreq: muscleunit: eatout: numinfu: age: numcigsn: numcigse: smokestartn: smokestarte: smokestop: cancrloc1: cancrloc2: cancrlimit: diablimit: heartlimit: hibplimit: lunglimit: heartalimit: stroklimit: strokeage: heartattackage: heartdiseaseage: hypertensionage: asthmaage: lungdiseaseage: diabetesage: arthritisage: memorylossage: learningdisorderage: cancerage: psychprobage: chroncondage: strokedays: strokemnth: strokeweek: strokeyear: hibpdays: hibpmnth: hibpweek: hibpyear: diabdays: diabmnth: diabweek: diabyear: cancrdays: cancrmnth: cancrweek: cancryear: lungdays: lungmnth: lungweek: lungyear: heartattackdays: heartattackmnth: heartattackweek: heartattackyear: heartdiseasedays: heartdiseasemnth: heartdiseaseweek: heartdiseaseyear: psychprobdays: psychprobmnth: psychprobweek: psychprobyear: arthritisdays: arthritismnth: arthritisweek: arthritisyear: asthmadays: asthmamnth: asthmaweek: asthmayear: memorylossdays: memorylossmnth: memorylossweek: memorylossyear: learningdisorderdays: learningdisordermnth: learningdisorderweek: learningdisorderyear: resp: alcohol: alcdrinks: alcfreq: asthm: alcbinge: satisfaction: ); array age_[*] %listyrv(age,begy=1999); array age_imp_[*] %listyrv(age_imp,begy=1999); /* impute age if interview was skipped */ do i = dim(age_) to 2 by -1; if (14 le age_[i] le 120) & (age_[i-1] lt 14 or age_[i-1] gt 120) then do; age_[i-1] = age_[i]-2; if age_imp_[i-1] = . then age_imp_[i-1]=1; end; end; do i = 1 to dim(age_)-1; if (14 le age_[i] le 120) & (age_[i+1] lt 14 or age_[i+1] gt 120) then do; age_[i+1] = age_[i]+2; if age_imp_[i+1] = . then age_imp_[i+1] = 1; end; end; array shlt_[*] %listyrv(shlt,begy=1999); array srh_[*] %listyrv(srh,begy=1999); array inyr_[*] %listyrv(inyr,begy=1999); /* Self-reported health before age 17 */ do i = 1 to dim(srh_); if srh_[i] = 0 then srh_[i] = .; else if srh_[i] = 8 then srh_[i] = .; else if srh_[i] = 9 then srh_[i] = .; else if srh_[i] = 5 then srh_[i] = 1; /* Poor */ else if srh_[i] = 4 then srh_[i] = 2; /* Fair */ else if srh_[i] = 3 then srh_[i] = 3; /* Good */ else if srh_[i] = 2 then srh_[i] = 4; /* Very good */ else if srh_[i] = 1 then srh_[i] = 5; /* Excellent */ end; do i=1 to dim(shlt_); if 3 le srh_[i] le 5 then shlt_[i] = 0; else if 1 le srh_[i] le 2 then shlt_[i] = 1; end; label %labelyrv(srh,Self-report of health 1 = fair 5 = excellent,begy=1999); label %labelyrv(shlt,Binary self-report of health 1 = fair/poor,begy=1999); /* Generate weight, height, and BMI variables */ array bmi_[*] %listyrv(bmi,begy=1999); array wght_[*] %listyrv(wght,begy=1999); array wghtkg_[*] %listyrv(wghtkg,begy=1999); /* weight in kg wasn't asked until 2011 but set here to 1999 so that array loops below are not breaking */ array totalwght_[*] %listyrv(totalwght,begy=1999); /* weight in kg */ array heightft_[*] %listyrv(heightft,begy=1999); array heightin_[*] %listyrv(heightin,begy=1999); array heightmt_[*] %listyrv(heightmt,begy=1999); /* height in meters wasn't asked until 2011 but set here to 1999 so that array loops below are not breaking */ array totalheight_[*] %listyrv(totalheight,begy=1999); /* height in meters. NB: BMI will be calculated with avg_totalheight variable */ array totalheightin_[*] %listyrv(totalheightin,begy=1999); /* intermediate variable that is total height in inches (from feet + inches) */ array bmi_minmax_[*] %listyrv(bmi_minmax,begy=1999); /* flag for bmi based on height or weight at/below the min or at/above the max response values */ array wght_imp_[*] %listyrv(wght_imp,begy=1999); /* flag for imputation of weight */ /* HEIGHT: calculate height in meters using heightft (in feet), heightin (in inches) and heightmt (in meters) */ height_sum_all_years=.; /* initialize numerator for calculating the mean height for imputation below */ response_counter=.; /* initialize denominator for calculating the mean height for imputation below */ do i = 1 to dim(totalheight_); /* assign height in meters if available */ if (0.6<=heightmt_[i]<=2.10) then do; totalheight_[i]=heightmt_[i]; if (20<=age_[i]<120) then do; /* running total to determine the mean for all years after age 20, for imputation below */ height_sum_all_years=sum(height_sum_all_years,totalheight_[i]); response_counter+1; end; end; /* if no answer in meters, use ft & in if available*/ if missing(totalheight_[i]) then do; /* if ft and in are valid answers, convert first to total inches */ if (2<=heightft_[i]<=7) & (0<=heightin_[i]<=11) then do; /* intermediate variable that is total height in inches (from feet + inches) */ totalheightin_[i] = (heightft_[i]*12)+heightin_[i]; /* convert all valid values in inches to meters */ if (24== 998 then lgtexcfreq_[i] = . ; if lgtexcunit_[i] = 2 then dlylgtexc_[i] = lgtexcfreq_[i]; else if lgtexcunit_[i] = 3 then dlylgtexc_[i] = lgtexcfreq_[i]/7; else if lgtexcunit_[i] = 4 then dlylgtexc_[i] = lgtexcfreq_[i]/14; else if lgtexcunit_[i] = 5 then dlylgtexc_[i] = lgtexcfreq_[i]/30; else if lgtexcunit_[i] = 6 then dlylgtexc_[i] = lgtexcfreq_[i]/365; else if 7 <= lgtexcunit_[i] <= 9 then dlylgtexc_[i] = .; else if lgtexcunit_[i] = 0 then dlylgtexc_[i] = 0; end; do i = 1 to dim(hvyexcfreq_); /* Handle missing/refused */ if hvyexcfreq_[i] >= 998 then hvyexcfreq_[i] = . ; if hvyexcunit_[i] = 2 then dlyhvyexc_[i] = hvyexcfreq_[i]; else if hvyexcunit_[i] = 3 then dlyhvyexc_[i] = hvyexcfreq_[i]/7; else if hvyexcunit_[i] = 4 then dlyhvyexc_[i] = hvyexcfreq_[i]/14; else if hvyexcunit_[i] = 5 then dlyhvyexc_[i] = hvyexcfreq_[i]/30; else if hvyexcunit_[i] = 6 then dlyhvyexc_[i] = hvyexcfreq_[i]/365; else if 7 <= hvyexcunit_[i] <= 9 then dlyhvyexc_[i] = .; else if hvyexcunit_[i] = 0 then dlyhvyexc_[i] = 0; end; do i = 1 to dim(musclefreq_); /* Handle missing/refused */ if musclefreq_[i] >= 998 then musclefreq_[i] = . ; if muscleunit_[i] = 2 then dlymuscle_[i] = musclefreq_[i]; else if muscleunit_[i] = 3 then dlymuscle_[i] = musclefreq_[i]/7; else if muscleunit_[i] = 4 then dlymuscle_[i] = musclefreq_[i]/14; else if muscleunit_[i] = 5 then dlymuscle_[i] = musclefreq_[i]/30; else if muscleunit_[i] = 6 then dlymuscle_[i] = musclefreq_[i]/365; else if 7 <= muscleunit_[i] <= 9 then dlymuscle_[i] = .; else if muscleunit_[i] = 0 then dlymuscle_[i] = 0; end; /* include possitive responses to heart attack question in heart disease responses */ do i = 1 to dim(heart_); heart_old_[i] = heart_[i]; if heart_[i] ne 1 & 1 le hearta_[i] le 5 then do; heart_[i] = hearta_[i]; if heart_old_[i] ne heart_[i] then heart_imp_[i] = 1; end; end; /* Cancer type - find if ONLY skin cancer */ do i = 1 to dim(cancr_); /* skin cancer only - first response is skin cancer, no cancer in second response */ if cancrloc1_[i] = 7 and cancrloc2_[i] = 0 then skincanc_[i] = 1; /* If only skin cancer (melanoma is own category), then set cancer to 0 */ if skincanc_[i] = 1 then cancr_[i] = 0; end; /* Recode the "does the disease limit your normal activities" variables */ do i = 1 to dim(cancrlimit_); %severity(cancrlimit diablimit heartlimit hibplimit lunglimit heartalimit stroklimit) /* recodes to 1 = not at all, 2 = just a little, 3 = somewhat, 4 = a lot */ end; /* Deal with individuals who respond that they have lung disease, but it does not impact their life. We think this is a question wording issue where folks who had bronchitis (not chronic bronchitis) are responding "yes" to having chronic lung problems */ do i = 1 to dim(lung_); if lung_[i] = 1 and lunglimit_[i] = 1 then lung_[i] = 5; end; /* Recode the 0, 1, 5, 8, 9 values for health conditions */ %recode_absorb(heart lung) /* Do not allow for disputes */ %recode_absorb_dispute(cancr diab hibp strok asthm) /* Allow for disputes */ /* Address missing values for absorbed values: 1. Fill forward if missing and lag is 1 2. fill backward if missing and next is 0 3. set to 0 if still missing */ %fill_missing(hearte); %fill_missing(stroke); %fill_missing(cancre); %fill_missing(diabe); %fill_missing(hibpe); %fill_missing(lunge); %fill_missing(asthme); /* fill forward smokev for individuals who changed to 0 */ do i = 2 to dim(smokev_); if smokev_[i-1] = 1 then do; smokev_[i] = 1; end; end; /* drop non-absorbed versions of variables */ drop cancr cancrnow diab diabnow heart heartnow hibp hibpnow lung lungnow strok stroknow deathyr asthm ; /* Address $ eating out questions, controlling for number of people in FU Units: 2 = day, 3 = week, 4 = two weeks, 5 = month, 6 = year, 7 = other, 8 = DK, 9 = NA/refuse, 0 = inappropriate */ array eatoutfs_[*] %listyrv(eatoutfs,begy=1999); array eatoutfsunit_[*] %listyrv(eatoutfsunit,begy=1999); array eatout_[*] %listyrv(eatout,begy=1999); array eatoutunit_[*] %listyrv(eatoutunit,begy=1999); array numinfu_[*] %listyrv(numinfu,begy=1999); array dineoutcost_[*] %listyrv(dineoutcost,begy=1999); do i = 1 to dim(eatoutfs_); if 99998 <= eatoutfs_[i] <= 99999 then eatoutfs_[i] = .; end; do i = 1 to dim(eatout_); if 99998 <= eatout_[i] <= 99999 then eatout_[i] = .; end; do i = 1 to dim(dineoutcost_); /* those receiving food stamps */ if eatoutfsunit_[i] = 2 then dineoutcost_[i] = (eatoutfs_[i]*30)/numinfu_[i]; /* daily */ else if eatoutfsunit_[i] = 3 then dineoutcost_[i] = (eatoutfs_[i]*4.29)/numinfu_[i]; /* weekly */ else if eatoutfsunit_[i] = 4 then dineoutcost_[i] = (eatoutfs_[i]*2.14)/numinfu_[i]; /* semi-weekly */ else if eatoutfsunit_[i] = 5 then dineoutcost_[i] = (eatoutfs_[i])/numinfu_[i]; /* monthly */ else if eatoutfsunit_[i] = 6 then dineoutcost_[i] = (eatoutfs_[i] *(1/12) )/numinfu_[i]; /* annual */ else if 7 <= eatoutfsunit_[i] <= 9 then dineoutcost_[i] = . ; /* other, don't know, refused */ /* those who do not receive food stamps */ if eatoutunit_[i] = 2 then dineoutcost_[i] = (eatout_[i]*30)/numinfu_[i]; /* daily */ else if eatoutunit_[i] = 3 then dineoutcost_[i] = (eatout_[i]*4.29)/numinfu_[i]; /* weekly */ else if eatoutunit_[i] = 4 then dineoutcost_[i] = (eatout_[i]*2.14)/numinfu_[i]; /* semi-weekly */ else if eatoutunit_[i] = 5 then dineoutcost_[i] = (eatout_[i])/numinfu_[i]; /* monthly */ else if eatoutunit_[i] = 6 then dineoutcost_[i] = (eatout_[i] *(1/12) )/numinfu_[i]; /* annual */ else if 7 <= eatoutunit_[i] <= 9 then dineoutcost_[i] = . ; /* other, don't know, refused */ end; /* Recode the most prevalent "other chronic condition" (Bone disorder, arthritis, scoliosis, joint disorder (2)) and determine onset (incl a dummy for age of onset before certain age). Other "other chronic conditions" that can be derived with this macro from the survey question are (with the value for the answer): seizures (1), kidney disease (3), coronary problem (4), anemia (5), allergies (6), autoimmune disorder; Graves', Crohn's, lupus, psoriasis, scleroderma, myasthenia gravis, celiac disease, Guillain-Barre (7), nerve disorder; Parkinson's (8), thyroid (9), Inflammation, infection; MS, sarcoidosis, eczema (10), eye/ear problems (20), fibromyalgia, chronic fatigue syndromw (21), Circulatory/blood problems; arterial/venous disorders, Factor V leiden, blood clots, PAD, polysythemia vera (22), sleep apnea, sleep disorders (23), migraines, chronic headaches (24), high cholesterol (25), Digestive disorder, gastrointestinal disease; GERD, acid reflux, gastritis, ibs, ulcers, colitis, chronic intestinal problems (26), Other; Reynaud syndrome, prostate problems, hypoglycemia, dementia, weight problems, fibroid tumors, cysts, hernia, etc (97), DK (98), NA; refused (99), Inap.: never been diagnosed with any other chronic condition (ER68497=5); DK, NA, or RF whether ever been diagnosed with any other chronic condition (ER68497=8 or 9) (0) NB: prevalence is low due to this being an open-ended question - use at your own risk */ %chron_cond(chronvar=bone_dis,agevar=bone_disorder_age,answer=2,ageonset_cutoff=25,ageonset_cutoffvar=bone_disorder); /* Recode the age of onset for diseases of interest. Create dummy variables for onset by age25, by age30 - For 1999-2003 age of onset needs to be calculated from the "how long have you had this condition" question - For 2005-present age of onset is asked directly */ array agecalc_[*] %listyrv(age,begy=1999,endy=2003); /* Calculate the onset age for 1999-2003 survey years */ %calc_onset(stroke,begy=1999,endy=2003); %calc_onset(heartattack,begy=1999,endy=2003); %calc_onset(heartdisease,begy=1999,endy=2003); %calc_onset(hibp,begy=1999,endy=2003); %calc_onset(asthma,begy=1999,endy=2003); %calc_onset(lung,begy=1999,endy=2003); %calc_onset(diab,begy=1999,endy=2003); %calc_onset(arthritis,begy=1999,endy=2003); %calc_onset(memoryloss,begy=1999,endy=2003); %calc_onset(learningdisorder,begy=1999,endy=2003); %calc_onset(cancr,begy=1999,endy=2003); %calc_onset(psychprob,begy=1999,endy=2003); /* Name variables consistently where we haven't */ hypertensionage99 = hibpage99; hypertensionage01 = hibpage01; hypertensionage03 = hibpage03; lungdiseaseage99 = lungage99; lungdiseaseage01 = lungage01; lungdiseaseage03 = lungage03; diabetesage99 = diabage99; diabetesage01 = diabage01; diabetesage03 = diabage03; cancerage99 = cancrage99; cancerage01 = cancrage01; cancerage03 = cancrage03; /* Create the full arrays 1999-present */ array strokeage_[*] %listyrv(strokeage,begy=1999); array heartattackage_[*] %listyrv(heartattackage,begy=1999); array heartdiseaseage_[*] %listyrv(heartdiseaseage,begy=1999); array hypertensionage_[*] %listyrv(hypertensionage,begy=1999); array asthmaage_[*] %listyrv(asthmaage,begy=1999); array lungdiseaseage_[*] %listyrv(lungdiseaseage,begy=1999); array diabetesage_[*] %listyrv(diabetesage,begy=1999); array arthritisage_[*] %listyrv(arthritisage,begy=1999); array memorylossage_[*] %listyrv(memorylossage,begy=1999); array learningdisorderage_[*] %listyrv(learningdisorderage,begy=1999); array cancerage_[*] %listyrv(cancerage,begy=1999); array psychprobage_[*] %listyrv(psychprobage,begy=1999); /* Array indicating who the respondent was (1 = the person, 5 = proxy ) */ array resp_[*] %listyrv(resp,begy=1999); /* Dummy variables for onset by age 25 */ %onset(stroke,25); %onset(heartattack,25); %onset(heartdisease,25); %onset(hypertension,25); %onset(asthma,25); %onset(lungdisease,25); %onset(diabetes,25); %onset(arthritis,25); %onset(memoryloss,25); %onset(learningdisorder,25); %onset(cancer,25); %onset(psychprob,25); /* Rename */ fstrok25 = stroke25; fheartattack25 = heartattack25; fheart25 = heartdisease25; fhibp25 = hypertension25; fasthma25 = asthma25; flung25 = lungdisease25; fdiab25 = diabetes25; farthritis25 = arthritis25; fmemry25 = memoryloss25; flearndis25 = learningdisorder25; fcancr25 = cancer25; fpsych25 = psychprob25; /* Dummy variables for onset by age 30 */ %onset(stroke,30); %onset(heartattack,30); %onset(heartdisease,30); %onset(hypertension,30); %onset(asthma,30); %onset(lungdisease,30); %onset(diabetes,30); %onset(arthritis,30); %onset(memoryloss,30); %onset(learningdisorder,30); %onset(cancer,30); %onset(psychprob,30); /* Rename */ fstrok30 = stroke30; fheartattack30 = heartattack30; fheart30 = heartdisease30; fhibp30 = hypertension30; fasthma30 = asthma30; flung30 = lungdisease30; fdiab30 = diabetes30; farthritis30 = arthritis30; fmemry30 = memoryloss30; flearndis30 = learningdisorder30; fcancr30 = cancer30; fpsych30 = psychprob30; label %labelyrv(cancre,Doctor ever told you that you have cancer excluding skin cancer,begy=1999); label %labelyrv(diabe,Doctor ever told you that you have diabetes,begy=1999); * label %labelyrv(hearte,Doctor ever coronary heart disease angina or congestive heart failure,begy=1999); label %labelyrv(hearte,Doctor ever heart attack coronary heart disease angina or congestive heart failure,begy=1999); label %labelyrv(hibpe,Doctor ever told you that you have high blood pressure,begy=1999); label %labelyrv(lunge,Doctor ever told you that you have chronic lung disease,begy=1999); label %labelyrv(stroke,Doctor ever told you that you have stroke,begy=1999); label bone_disorder25 = 'Dx < age 25 w bone disorder/arthritis/etc. NB: Open-ended question, may not be reliable'; label %labelyrv(smoken,Do you currently smoke,begy=1999); label %labelyrv(smokev,Did you ever smoke,begy=1999); label %labelyrv(dineoutcost,Monthly cost of eating out,begy=1999); keep id cancre: diabe: hearte: hibpe: lunge: stroke: smoken: smokev: bmi: totalwght: totalheight: avg_totalheight wght_imp: srh: shlt: deathyr: dlylgtexc: dlyhvyexc: dlymuscle: dineoutcost: heart_imp: cancrlimit: diablimit: heartlimit: hibplimit: lunglimit: heartalimit: stroklimit: yearssmoked: numcigs: packyears: smokestartmed f: strokeage: heartattackage: heartdiseaseage: hypertensionage: asthmaage: lungdiseaseage: diabetesage: arthritisage: memorylossage: learningdisorderage: cancerage: psychprobage: bone_disorder25 resp: alcohol: alcdrinks: alcfreq: alcbinge: asthme: satisfaction: ; drop heart_old: strokedays: strokemnth: strokeweek: strokeyear: hibpdays: hibpmnth: hibpweek: hibpyear: diabdays: diabmnth: diabweek: diabyear: cancrdays: cancrmnth: cancrweek: cancryear: lungdays: lungmnth: lungweek: lungyear: heartattackdays: heartattackmnth: heartattackweek: heartattackyear: heartdiseasedays: heartdiseasemnth: heartdiseaseweek: heartdiseaseyear: psychprobdays: psychprobmnth: psychprobweek: psychprobyear: arthritisdays: arthritismnth: arthritisweek: arthritisyear: asthmadays: asthmamnth: asthmaweek: asthmayear: memorylossdays: memorylossmnth: memorylossweek: memorylossyear: learningdisorderdays: learningdisordermnth: learningdisorderweek: learningdisorderyear: resp: totalheightin: stroke25 heartattack25 heartdisease25 hypertension25 asthma25 lungdisease25 diabetes25 arthritis25 memoryloss25 learningdisorder25 cancer25 psychprob25 stroke30 heartattack30 heartdisease30 hypertension30 asthma30 lungdisease30 diabetes30 arthritis30 memoryloss30 learningdisorder30 cancer30 psychprob30 ; run;