********************************************************************* MAY 29, 2012 2:53 PM This is an example of a SAS program that creates a SAS file from the 2011 NHIS Public Use FUNCDISB.DAT ASCII file This is stored in FUNCDISB.SAS *********************************************************************; * USER NOTE: PLACE NEXT STATEMENT IN SUBSEQUENT PROGRAMS; LIBNAME NHIS "C:\NHIS2011"; * USER NOTE: PLACE NEXT STATEMENT IN SUBSEQUENT PROGRAMS IF YOU ALLOW PROGRAM TO PERMANENTLY STORE FORMATS; LIBNAME LIBRARY "C:\NHIS2011"; FILENAME ASCIIDAT 'C:\NHIS2011\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" 38 = "38 Functioning and Disability" 39 = "39 Adult Disability Questions Test" 40 = "40 Sample Child" 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 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 AFP013X 1 = "1 Yes" 2 = "2 No" 7 = "7 Refused" 8 = "8 Not ascertained" 9 = "9 Don't know" ; VALUE AFP014X 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 AFP035X 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 AFP036X 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 AFP037X 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 AFP041X 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 AFP043X 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 AFP044X 1 = "1 Closer to a little" 2 = "2 Closer to a lot" 3 = "3 Exactly in the middle" 7 = "7 Refused" 8 = "8 Not ascertained" 9 = "9 Don't know" ; VALUE AFP052X 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 AFP053X 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 AFP060X 1 = "1 Not at all" 2 = "2 A little" 3 = "3 A lot" 4 = "4 Completely" 7 = "7 Refused" 8 = "8 Not ascertained" 9 = "9 Don't know" ; VALUE AFP061X 1 = "1 Do the activity" 2 = "2 Don't do the activity" 3 = "3 Unable to do the activity" 7 = "7 Refused" 8 = "8 Not ascertained" 9 = "9 Don't know" ; VALUE AFP069X 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=89; * 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 /* AFD LENGTHS */ VIS_SS 3 HEAR_SS 3 HEAR_1 3 HEAR_2 3 HEAR_3 3 HEAR_4 3 MOB_SS 3 MOB_2 3 MOB_3A 3 MOB_3B 3 MOB_3C 3 MOB_3D2 3 MOB_3E 3 MOB_3F 3 MOB_3G 3 MOB_4 3 MOB_5 3 MOB_6 3 MOB_7 3 MOB_8 3 MOB_9 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_3 3 ANX_4 3 P_ANX_4C 3 P_ANX_4D 3 DEP_1 3 DEP_2 3 DEP_3 3 DEP_4 3 P_DEP_4C 3 PAIN_2 3 PAIN_3 3 PAIN_4 3 PAIN_5 3 TIRED_1 3 TIRED_2 3 TIRED_3 3 TIRED_4 3 QOL_1 3 QOL_2B 3 QOL_2C 3 QOL_2D 3 QOL_2E 3 QOL_2F 3 QOL_2G 3 QOL_2H 3 QOL_2I 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 /* AFD LOCATIONS */ VIS_SS 31 - 31 HEAR_SS 32 - 32 HEAR_1 33 - 33 HEAR_2 34 - 34 HEAR_3 35 - 35 HEAR_4 36 - 36 MOB_SS 37 - 37 MOB_2 38 - 38 MOB_3A 39 - 39 MOB_3B 40 - 40 MOB_3C 41 - 41 MOB_3D2 42 - 42 MOB_3E 43 - 43 MOB_3F 44 - 44 MOB_3G 45 - 45 MOB_4 46 - 46 MOB_5 47 - 47 MOB_6 48 - 48 MOB_7 49 - 49 MOB_8 50 - 50 MOB_9 51 - 51 COM_SS 52 - 52 COM_2 53 - 53 COG_SS 54 - 54 COG_1 55 - 55 COG_2 56 - 56 COG_3 57 - 57 UB_SS 58 - 58 UB_1 59 - 59 UB_2 60 - 60 ANX_1 61 - 61 ANX_2 62 - 62 ANX_3 63 - 63 ANX_4 64 - 64 P_ANX_4C 65 - 65 P_ANX_4D 66 - 66 DEP_1 67 - 67 DEP_2 68 - 68 DEP_3 69 - 69 DEP_4 70 - 70 P_DEP_4C 71 - 71 PAIN_2 72 - 72 PAIN_3 73 - 73 PAIN_4 74 - 74 PAIN_5 75 - 75 TIRED_1 76 - 76 TIRED_2 77 - 77 TIRED_3 78 - 78 TIRED_4 79 - 79 QOL_1 80 - 80 QOL_2B 81 - 81 QOL_2C 82 - 82 QOL_2D 83 - 83 QOL_2E 84 - 84 QOL_2F 85 - 85 QOL_2G 86 - 86 QOL_2H 87 - 87 QOL_2I 88 - 88 RCS_AFD 89 - 89; * 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" /* AFD LABELS */ VIS_SS ="Degree of difficulty seeing" HEAR_SS ="Degree of difficulty hearing" HEAR_1 ="Do you use a hearing aid?" HEAR_2 ="How often do you use a hearing aid?" 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_SS ="Degree of difficulty walking or climbing steps" MOB_2 ="Use equipment to help walk, climb stairs, or move around?" MOB_3A ="Use cane or walking stick?" MOB_3B ="Use a walker?" MOB_3C ="Use crutches?" MOB_3D2 ="Use a wheelchair or scooter?" MOB_3E ="Use prosthesis?" 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" MOB_9 ="Degree of difficulty walking up or down 12 steps using aid" 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_3 = "Level of feelings when you last felt worried, nervous, or anxious?" ANX_4 = "Last worried, nervous, or anxious feelings were closer to a little, closer to a lot, or exactly in the middle?" P_ANX_4C = "Worried, nervous, or anxious feelings help me to accomplish goals and be produc tive" P_ANX_4D = "Worried, nervous, or anxious feelings sometimes interfere with my life and I wi sh I did not have them" DEP_1 ="How often do you feel depressed?" DEP_2 ="Take medication for depression?" DEP_3 ="How depressed you felt last time you were depressed?" DEP_4 = "Was the level of most recent depression closer to a little, closer to a lot, or exactly in the middle?" P_DEP_4C = "Feelings of depression sometimes interfere with my life and I wish I did not ha ve them" PAIN_2 ="Frequency of pain in past 3 months" PAIN_3 ="How long pain lasted last time you had it?" PAIN_4 ="How much pain you had last time you had pain?" PAIN_5 = "Was level of most recent pain closer to a little, closer to a lot, or exactly i n the middle?" 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" TIRED_4 = "Level of tiredness closer to a little, closer to a lot, or exactly in the middl e" QOL_1 ="How limited are you in carrying out daily activities?" QOL_2B ="Working outside the home to earn an income?" QOL_2C ="Going to school or achieving your education goals?" QOL_2D ="Participating in leisure or social activities?" QOL_2E ="Getting out with friends or family?" QOL_2F ="Doing household chores such as cooking and cleaning?" QOL_2G ="Using transportation to get to places you want to go?" QOL_2H ="Participating in religious activities?" QOL_2I ="Participating in community gatherings?" 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 */ /* AFD FORMAT ASSOCIATIONS */ VIS_SS AFP011X. HEAR_SS AFP011X. HEAR_1 AFP013X. HEAR_2 AFP014X. HEAR_3 AFP011X. HEAR_4 AFP011X. MOB_SS AFP011X. MOB_2 AFP013X. MOB_3A AFP013X. MOB_3B AFP013X. MOB_3C AFP013X. MOB_3D2 AFP013X. MOB_3E AFP013X. MOB_3F AFP013X. MOB_3G AFP013X. MOB_4 AFP011X. MOB_5 AFP011X. MOB_6 AFP011X. MOB_7 AFP011X. MOB_8 AFP011X. MOB_9 AFP011X. COM_SS AFP011X. COM_2 AFP013X. COG_SS AFP011X. COG_1 AFP035X. COG_2 AFP036X. COG_3 AFP037X. UB_SS AFP011X. UB_1 AFP011X. UB_2 AFP011X. ANX_1 AFP041X. ANX_2 AFP013X. ANX_3 AFP043X. ANX_4 AFP044X. P_ANX_4C AFP013X. P_ANX_4D AFP013X. DEP_1 AFP041X. DEP_2 AFP013X. DEP_3 AFP043X. DEP_4 AFP044X. P_DEP_4C AFP013X. PAIN_2 AFP052X. PAIN_3 AFP053X. PAIN_4 AFP043X. PAIN_5 AFP044X. TIRED_1 AFP052X. TIRED_2 AFP053X. TIRED_3 AFP043X. TIRED_4 AFP044X. QOL_1 AFP060X. QOL_2B AFP061X. QOL_2C AFP061X. QOL_2D AFP061X. QOL_2E AFP061X. QOL_2F AFP061X. QOL_2G AFP061X. QOL_2H AFP061X. QOL_2I AFP061X. RCS_AFD AFP069X.; RUN; PROC CONTENTS DATA=NHIS.FUNCDISB; TITLE1 'CONTENTS OF THE 2011 NHIS Functioning and Disability FILE'; PROC FREQ DATA=NHIS.FUNCDISB NOTITLE; TABLES RECTYPE/LIST MISSING; TITLE1 'FREQUENCY REPORT FOR 2011 NHIS Functioning and Disability FILE'; TITLE2 '(WEIGHTED)'; WEIGHT WTFA_AFD; PROC FREQ DATA=NHIS.FUNCDISB NOTITLE; TABLES RECTYPE/LIST MISSING; TITLE1 'FREQUENCY REPORT FOR 2011 NHIS Functioning and Disability FILE'; TITLE2 '(UNWEIGHTED)'; * USER NOTE: TO SEE UNFORMATTED VALUES IN PROCEDURES, ADD THE STATEMENT: FORMAT _ALL_; RUN;