********************************************************************* APRIL 5, 2013 12:30 PM This is an example of a SAS program that creates a SAS file from the 2012 NHIS Public Use FUNCDISB.DAT ASCII file This is stored in FUNCDISB.SAS *********************************************************************; * USER NOTE: PLACE NEXT STATEMENT IN SUBSEQUENT PROGRAMS; LIBNAME NHIS "C:\NHIS2012"; * USER NOTE: PLACE NEXT STATEMENT IN SUBSEQUENT PROGRAMS IF YOU ALLOW PROGRAM TO PERMANENTLY STORE FORMATS; LIBNAME LIBRARY "C:\NHIS2012"; FILENAME ASCIIDAT 'C:\NHIS2012\FUNCDISB.dat'; * DEFINE VARIABLE VALUES FOR REPORTS; * USE THE STATEMENT "PROC FORMAT LIBRARY=LIBRARY" TO PERMANENTLY STORE THE FORMAT DEFINITIONS; * USE THE STATEMENT "PROC FORMAT" IF YOU DO NOT WISH TO PERMANENTLY STORE THE FORMATS; PROC FORMAT LIBRARY=LIBRARY; *PROC FORMAT; VALUE $GROUPC ' '< - HIGH = "Range of Values" ; VALUE GROUPN LOW - HIGH = "Range of Values" ; VALUE AFP001X 10 = "10 Household" 20 = "20 Person" 25 = "25 Income Imputation" 30 = "30 Sample Adult" 31 = "31 Sample Adult Cancer" 34 = "34 Adult Alternative Medicine" 38 = "38 Functioning and Disability" 39 = "39 Adult Disability Questions Test" 40 = "40 Sample Child" 44 = "44 Child Alternative Medicine" 49 = "49 Child Disability Questions Test" 60 = "60 Family" 63 = "63 Family Disability Questions Test" 65 = "65 Paradata" 70 = "70 Injury/Poisoning Episode" 75 = "75 Injury/Poisoning Verbatim" ; VALUE AFP002X . = '.' OTHER = "Survey Year" ; VALUE AFP004X 1 = "1 Quarter 1" 2 = "2 Quarter 2" 3 = "3 Quarter 3" 4 = "4 Quarter 4" ; VALUE AFP005X 01 = "01 January" 02 = "02 February" 03 = "03 March" 04 = "04 April" 05 = "05 May" 06 = "06 June" 07 = "07 July" 08 = "08 August" 09 = "09 September" 10 = "10 October" 11 = "11 November" 12 = "12 December" ; VALUE AFP011X 1 = "1 Families selected to receive ADB (sample adults) and CDB (sample children 1-1 7 years) sections" 2 = "2 Families selected to receive FDB (all persons 1 year and older) sections" ; VALUE AFP012X 1 = "1 Sample Adult selected to receive AFD section" 2 = "2 Sample Adult not selected to receive AFD section" ; VALUE AFP013X 1 = "1 Yes" 2 = "2 No" 7 = "7 Refused" 8 = "8 Not ascertained" 9 = "9 Don't know" ; VALUE AFP014X 1 = "1 No difficulty" 2 = "2 Some difficulty" 3 = "3 A lot of difficulty" 4 = "4 Cannot do at all/unable to do" 7 = "7 Refused" 8 = "8 Not ascertained" 9 = "9 Don't know" ; VALUE AFP016X 1 = "1 All of the time" 2 = "2 Some of the time" 3 = "3 Rarely" 4 = "4 Never" 7 = "7 Refused" 8 = "8 Not ascertained" 9 = "9 Don't know" ; VALUE AFP037X 1 = "1 Difficulty remembering only" 2 = "2 Difficulty concentrating only" 3 = "3 Difficulty with both remembering and concentrating " 7 = "7 Refused" 8 = "8 Not ascertained" 9 = "9 Don't know" ; VALUE AFP038X 1 = "1 Sometimes" 2 = "2 Often" 3 = "3 All of the time" 7 = "7 Refused" 8 = "8 Not ascertained" 9 = "9 Don't know" ; VALUE AFP039X 1 = "1 A few things" 2 = "2 A lot of things" 3 = "3 Almost everything" 7 = "7 Refused" 8 = "8 Not ascertained" 9 = "9 Don't know" ; VALUE AFP043X 1 = "1 Daily" 2 = "2 Weekly" 3 = "3 Monthly" 4 = "4 A few times a year" 5 = "5 Never" 7 = "7 Refused" 8 = "8 Not ascertained" 9 = "9 Don't know" ; VALUE AFP045X 1 = "1 A little" 2 = "2 A lot" 3 = "3 Somewhere in between a little and a lot" 7 = "7 Refused" 8 = "8 Not ascertained" 9 = "9 Don't know" ; VALUE AFP049X 1 = "1 Never" 2 = "2 Some days" 3 = "3 Most days" 4 = "4 Every day" 7 = "7 Refused" 8 = "8 Not ascertained" 9 = "9 Don't know" ; VALUE AFP052X 1 = "1 Some of the day" 2 = "2 Most of the day" 3 = "3 All of the day" 7 = "7 Refused" 8 = "8 Not ascertained" 9 = "9 Don't know" ; VALUE AFP054X 1 = "1 Not ascertained answers only" 2 = "2 Refused and don't know answers only" 3 = "3 Refused, DK, and not ascertained answers only" 4 = "4 At least one valid answer" ; DATA NHIS.FUNCDISB; * CREATE A SAS DATA SET; INFILE ASCIIDAT PAD LRECL=74; * DEFINE LENGTH OF ALL VARIABLES; LENGTH /* IDN LENGTHS */ RECTYPE 3 SRVY_YR 4 HHX $ 6 INTV_QRT 3 INTV_MON 3 FMX $ 2 FPX $ 2 WTFA_AFD 8 /* UCF LENGTHS */ STRAT_P 4 PSU_P 3 /* FDB LENGTHS */ FDRN_FLG 3 /* FRT LENGTHS */ AFD_FLG 3 /* AFD LENGTHS */ VIS_0 3 VIS_SS2 3 HEAR_1R 3 HEAR_2R 3 HEAR_SS2 3 HEAR_3 3 HEAR_4 3 MOB_SS2 3 MOB_2R 3 MOB_3A 3 MOB_3B2 3 MOB_3C 3 MOB_3D2 3 MOB_3E2 3 MOB_3F 3 MOB_3G 3 MOB_4 3 MOB_5 3 MOB_6 3 MOB_7 3 MOB_8 3 COM_SS 3 COM_2 3 COG_SS 3 COG_1 3 COG_2 3 COG_3 3 UB_SS 3 UB_1 3 UB_2 3 ANX_1 3 ANX_2 3 ANX_3R 3 DEP_1 3 DEP_2 3 DEP_3R 3 PAIN_2 3 PAIN_4 3 TIRED_1 3 TIRED_2 3 TIRED_3 3 RCS_AFD 3 ; * INPUT ALL VARIABLES; INPUT /* IDN LOCATIONS */ RECTYPE 1 - 2 SRVY_YR 3 - 6 HHX $ 7 - 12 INTV_QRT 13 - 13 INTV_MON 14 - 15 FMX $ 16 - 17 FPX $ 18 - 19 WTFA_AFD 20 - 25 /* UCF LOCATIONS */ STRAT_P 26 - 28 PSU_P 29 - 30 /* FDB LOCATIONS */ FDRN_FLG 31 - 31 /* FRT LOCATIONS */ AFD_FLG 32 - 32 /* AFD LOCATIONS */ VIS_0 33 - 33 VIS_SS2 34 - 34 HEAR_1R 35 - 35 HEAR_2R 36 - 36 HEAR_SS2 37 - 37 HEAR_3 38 - 38 HEAR_4 39 - 39 MOB_SS2 40 - 40 MOB_2R 41 - 41 MOB_3A 42 - 42 MOB_3B2 43 - 43 MOB_3C 44 - 44 MOB_3D2 45 - 45 MOB_3E2 46 - 46 MOB_3F 47 - 47 MOB_3G 48 - 48 MOB_4 49 - 49 MOB_5 50 - 50 MOB_6 51 - 51 MOB_7 52 - 52 MOB_8 53 - 53 COM_SS 54 - 54 COM_2 55 - 55 COG_SS 56 - 56 COG_1 57 - 57 COG_2 58 - 58 COG_3 59 - 59 UB_SS 60 - 60 UB_1 61 - 61 UB_2 62 - 62 ANX_1 63 - 63 ANX_2 64 - 64 ANX_3R 65 - 65 DEP_1 66 - 66 DEP_2 67 - 67 DEP_3R 68 - 68 PAIN_2 69 - 69 PAIN_4 70 - 70 TIRED_1 71 - 71 TIRED_2 72 - 72 TIRED_3 73 - 73 RCS_AFD 74 - 74 ; * DEFINE VARIABLE LABELS; LABEL /* IDN LABELS */ RECTYPE ="File type identifier" SRVY_YR ="Year of National Health Interview Survey" HHX ="Household Number" INTV_QRT ="Interview Quarter" INTV_MON ="Interview Month" FMX ="Family Number" FPX ="Person Number (Within family)" WTFA_AFD ="Weight - Final Annual Functioning and Disability file" /* UCF LABELS */ STRAT_P ="Pseudo-stratum for public-use file variance estimation" PSU_P ="Pseudo-PSU for public-use file variance estimation" /* FDB LABELS */ FDRN_FLG ="Disability Questions Test flag" /* FRT LABELS */ AFD_FLG ="Adult Functioning and Disability flag" /* AFD LABELS */ VIS_0 ="Does respondent wear glasses?" VIS_SS2 ="Degree of difficulty seeing" HEAR_1R ="Do you use a hearing aid?" HEAR_2R ="How often do you use a hearing aid?" HEAR_SS2 ="Degree of difficulty hearing" HEAR_3 = "Degree of difficulty hearing conversation with one person in quiet room" HEAR_4 = "Degree of difficulty hearing conversation with one person in noisier room even when wearing hearing aid" MOB_SS2 ="Degree of difficulty walking or climbing steps" MOB_2R ="Use equipment or receive help for getting around?" MOB_3A ="Use cane or walking stick?" MOB_3B2 ="Use a walker or Zimmer frame?" MOB_3C ="Use crutches?" MOB_3D2 ="Use a wheelchair or scooter?" MOB_3E2 ="Use artificial limb (leg/foot)?" MOB_3F ="Use someone's assistance?" MOB_3G ="Use other type of equipment or help?" MOB_4 = "Degree of difficulty walking 100 yards on level ground without the use of aid o r equipment" MOB_5 = "Degree of difficulty walking a third of a mile on level ground without the use of aid or equipment" MOB_6 = "Degree of difficulty walking up or down 12 steps without the use of aid or equi pment" MOB_7 = "Degree of difficulty walking 100 yards on level ground when using aid or equipm ent" MOB_8 = "Degree of difficulty walking a third of a mile on level ground when using aid o r equipment" COM_SS ="Degree of difficulty communicating using usual language" COM_2 ="Use sign language?" COG_SS ="Degree of difficulty remembering or concentrating" COG_1 ="Difficulty remembering, concentrating, or both?" COG_2 ="How often have difficulty remembering?" COG_3 ="Amount of things you have difficulty remembering?" UB_SS ="Degree of difficulty with self-care" UB_1 = "Degree of difficulty raising 2 liter bottle of water or soda from waist to eye level" UB_2 ="Degree of difficulty using hands and fingers" ANX_1 ="How often feel worried, nervous, or anxious?" ANX_2 ="Take medication for worried, nervous, or anxious feelings?" ANX_3R = "Level of feelings when you last felt worried, nervous, or anxious?" DEP_1 ="How often do you feel depressed?" DEP_2 ="Take medication for depression?" DEP_3R ="How depressed you felt last time you were depressed?" PAIN_2 ="Frequency of pain in past 3 months" PAIN_4 ="How much pain you had last time you had pain?" TIRED_1 ="How often felt very tired or exhausted in past 3 months" TIRED_2 ="How long most recent tired or exhausted feelings lasted?" TIRED_3 ="Level of tiredness last time felt very tired or exhausted" RCS_AFD ="Record completion status" ; * ASSOCIATE VARIABLES WITH FORMAT VALUES; * (PUT ASTERISK (*) BEFORE WORD "FORMAT" IN NEXT STATEMENT TO PREVENT FORMAT ASSOCIATIONS BEING STORED WITH DATA SET); FORMAT /* IDN FORMAT ASSOCIATIONS */ RECTYPE AFP001X. SRVY_YR AFP002X. HHX $GROUPC. INTV_QRT AFP004X. INTV_MON AFP005X. WTFA_AFD GROUPN. /* UCF FORMAT ASSOCIATIONS */ /* FDB FORMAT ASSOCIATIONS */ FDRN_FLG AFP011X. /* FRT FORMAT ASSOCIATIONS */ AFD_FLG AFP012X. /* AFD FORMAT ASSOCIATIONS */ VIS_0 AFP013X. VIS_SS2 AFP014X. HEAR_1R AFP013X. HEAR_2R AFP016X. HEAR_SS2 AFP014X. HEAR_3 AFP014X. HEAR_4 AFP014X. MOB_SS2 AFP014X. MOB_2R AFP013X. MOB_3A AFP013X. MOB_3B2 AFP013X. MOB_3C AFP013X. MOB_3D2 AFP013X. MOB_3E2 AFP013X. MOB_3F AFP013X. MOB_3G AFP013X. MOB_4 AFP014X. MOB_5 AFP014X. MOB_6 AFP014X. MOB_7 AFP014X. MOB_8 AFP014X. COM_SS AFP014X. COM_2 AFP013X. COG_SS AFP014X. COG_1 AFP037X. COG_2 AFP038X. COG_3 AFP039X. UB_SS AFP014X. UB_1 AFP014X. UB_2 AFP014X. ANX_1 AFP043X. ANX_2 AFP013X. ANX_3R AFP045X. DEP_1 AFP043X. DEP_2 AFP013X. DEP_3R AFP045X. PAIN_2 AFP049X. PAIN_4 AFP045X. TIRED_1 AFP049X. TIRED_2 AFP052X. TIRED_3 AFP045X. RCS_AFD AFP054X.; RUN; PROC CONTENTS DATA=NHIS.FUNCDISB; TITLE1 'CONTENTS OF THE 2012 NHIS Functioning and Disability FILE'; PROC FREQ DATA=NHIS.FUNCDISB NOTITLE; TABLES RECTYPE/LIST MISSING; TITLE1 'FREQUENCY REPORT FOR 2012 NHIS Functioning and Disability FILE'; TITLE2 '(WEIGHTED)'; WEIGHT WTFA_AFD; PROC FREQ DATA=NHIS.FUNCDISB NOTITLE; TABLES RECTYPE/LIST MISSING; TITLE1 'FREQUENCY REPORT FOR 2012 NHIS Functioning and Disability FILE'; TITLE2 '(UNWEIGHTED)'; * USER NOTE: TO SEE UNFORMATTED VALUES IN PROCEDURES, ADD THE STATEMENT: FORMAT _ALL_; RUN;