********************************************************************* JUNE 5, 2014 7:40 AM This is an example of a SAS program that creates a SAS file from the 2013 NHIS Public Use FUNCDISB.DAT ASCII file This is stored in FUNCDISB.SAS *********************************************************************; * USER NOTE: PLACE NEXT STATEMENT IN SUBSEQUENT PROGRAMS; LIBNAME NHIS "C:\NHIS2013"; * USER NOTE: PLACE NEXT STATEMENT IN SUBSEQUENT PROGRAMS IF YOU ALLOW PROGRAM TO PERMANENTLY STORE FORMATS; LIBNAME LIBRARY "C:\NHIS2013"; FILENAME ASCIIDAT 'C:\NHIS2013\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" 38 = "38 Functioning and Disability" 40 = "40 Sample Child" 60 = "60 Family" 63 = "63 Family Disability Questions" 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 AFD (sample adults) section" 2 = "2 Families selected to receive FDB (all persons 1 year and older) section" ; VALUE AFP012X 1 = "1 Yes" 2 = "2 No" 7 = "7 Refused" 8 = "8 Not ascertained" 9 = "9 Don't know" ; VALUE AFP013X 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 AFP015X 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 AFP036X 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 AFP037X 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 AFP038X 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 AFP042X 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 AFP044X 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 AFP048X 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 AFP051X 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 AFP053X 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=73; * 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 /* 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 /* AFD LOCATIONS */ VIS_0 32 - 32 VIS_SS2 33 - 33 HEAR_1R 34 - 34 HEAR_2R 35 - 35 HEAR_SS2 36 - 36 HEAR_3 37 - 37 HEAR_4 38 - 38 MOB_SS2 39 - 39 MOB_2R 40 - 40 MOB_3A 41 - 41 MOB_3B2 42 - 42 MOB_3C 43 - 43 MOB_3D2 44 - 44 MOB_3E2 45 - 45 MOB_3F 46 - 46 MOB_3G 47 - 47 MOB_4 48 - 48 MOB_5 49 - 49 MOB_6 50 - 50 MOB_7 51 - 51 MOB_8 52 - 52 COM_SS 53 - 53 COM_2 54 - 54 COG_SS 55 - 55 COG_1 56 - 56 COG_2 57 - 57 COG_3 58 - 58 UB_SS 59 - 59 UB_1 60 - 60 UB_2 61 - 61 ANX_1 62 - 62 ANX_2 63 - 63 ANX_3R 64 - 64 DEP_1 65 - 65 DEP_2 66 - 66 DEP_3R 67 - 67 PAIN_2 68 - 68 PAIN_4 69 - 69 TIRED_1 70 - 70 TIRED_2 71 - 71 TIRED_3 72 - 72 RCS_AFD 73 - 73 ; * 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 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 ="Difficulty hearing conversation with one person in quiet room " HEAR_4 ="Diff hearing one person in noisier room even w/ 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 ="Diff walking 100 yards on level ground w/o aid or equipment" MOB_5 ="Diff walking 1/3rd mile on level ground w/o aid or equipment" MOB_6 ="Diff walking up or down 12 steps w/o aid or equipment" MOB_7 ="Diff walking 100 yards on level ground w/ aid or equipment" MOB_8 ="Diff walking 1/3rd mile on level ground w/ aid or 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 ="Diff raising 2 liter bottle of water 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 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. /* AFD FORMAT ASSOCIATIONS */ VIS_0 AFP012X. VIS_SS2 AFP013X. HEAR_1R AFP012X. HEAR_2R AFP015X. HEAR_SS2 AFP013X. HEAR_3 AFP013X. HEAR_4 AFP013X. MOB_SS2 AFP013X. MOB_2R AFP012X. MOB_3A AFP012X. MOB_3B2 AFP012X. MOB_3C AFP012X. MOB_3D2 AFP012X. MOB_3E2 AFP012X. MOB_3F AFP012X. MOB_3G AFP012X. MOB_4 AFP013X. MOB_5 AFP013X. MOB_6 AFP013X. MOB_7 AFP013X. MOB_8 AFP013X. COM_SS AFP013X. COM_2 AFP012X. COG_SS AFP013X. COG_1 AFP036X. COG_2 AFP037X. COG_3 AFP038X. UB_SS AFP013X. UB_1 AFP013X. UB_2 AFP013X. ANX_1 AFP042X. ANX_2 AFP012X. ANX_3R AFP044X. DEP_1 AFP042X. DEP_2 AFP012X. DEP_3R AFP044X. PAIN_2 AFP048X. PAIN_4 AFP044X. TIRED_1 AFP048X. TIRED_2 AFP051X. TIRED_3 AFP044X. RCS_AFD AFP053X.; RUN; PROC CONTENTS DATA=NHIS.FUNCDISB; TITLE1 'CONTENTS OF THE 2013 NHIS Functioning and Disability FILE'; PROC FREQ DATA=NHIS.FUNCDISB NOTITLE; TABLES RECTYPE/LIST MISSING; TITLE1 'FREQUENCY REPORT FOR 2013 NHIS Functioning and Disability FILE'; TITLE2 '(WEIGHTED)'; WEIGHT WTFA_AFD; PROC FREQ DATA=NHIS.FUNCDISB NOTITLE; TABLES RECTYPE/LIST MISSING; TITLE1 'FREQUENCY REPORT FOR 2013 NHIS Functioning and Disability FILE'; TITLE2 '(UNWEIGHTED)'; * USER NOTE: TO SEE UNFORMATTED VALUES IN PROCEDURES, ADD THE STATEMENT: FORMAT _ALL_; RUN;