/* ---------------------------------------------------------------------------- The National Health Interview Survey (NHIS) 2019; Sample Adult Imputed Income data file This program loads the NHIS sample adult imputed income ASCII data file downloaded from the NCHS website (https://www.cdc.gov/nchs/nhis/index.htm) to a SAS dataset. The program creates descriptive variable labels and formats with meaningful category labels. It sets the variable lengths and uses input statements to read in the data. It ends with some sample proc freq calls to verify that the data were correctly loaded. Before running this program, please: - Download the sample adult imputed income ASCII file to a folder called C:\NHIS2019 (on a machine running Windows) - Configure the macro variables 'nhisfolder', 'adultincds' and 'formatcat' below. These variables set: the local folder where the ASCII file is located and where the SAS dataset will be saved, the name of the sample adult imputed income dataset, and the name of the catalog where formats are to be saved, respectively. */ /* Path to the folder where the NHIS ASCII file is located. Also where the permanent SAS dataset will be stored */ %let nhisfolder=C:\nhis2019; /* name of the dataset to load into */ %let adultincds=adultinc19; /* formats are stored temporarily in catalog in WORK.formats */ %let formatcat=WORK.formats; /* --- DO NOT EDIT BELOW THIS LINE --- */ libname NHIS "&nhisfolder"; filename ASCIIDAT "&nhisfolder\adultinc19.dat"; /* formats for variables */ proc format library=&formatcat; VALUE AI001X 0-219999 = "$0 to $219,999" 220000 = "220000 $220,000+" ; VALUE $AI002X '0' = "'0' Income reported" '1' = "'1' Income imputed; no other information" '2' = "'2' Income imputed; reported in income brackets" 'Blank' = "'Blank' No Sample Adult or Sample Child in household" ; VALUE AI003X 1 = "1 $0 to $34,999" 2 = "2 $35,000 to $49,999" 3 = "3 $50,000 to $74,999" 4 = "4 $75,000 to $99,999" 5 = "5 $100,000 or greater" 8 = "8 Not Ascertained" ; VALUE AI004X 01 = "01 0.00 - 0.49" 02 = "02 0.50 - 0.74" 03 = "03 0.75 - 0.99" 04 = "04 1.00 - 1.24" 05 = "05 1.25 - 1.49" 06 = "06 1.50 - 1.74" 07 = "07 1.75 - 1.99" 08 = "08 2.00 - 2.49" 09 = "09 2.50 - 2.99" 10 = "10 3.00 - 3.49" 11 = "11 3.50 - 3.99" 12 = "12 4.00 - 4.49" 13 = "13 4.50 - 4.99" 14 = "14 5.00 or greater" 98 = "98 Not Ascertained" ; VALUE AI005X 10 = "10 Sample Adult" 20 = "20 Sample Child" 30 = "30 Sample Adult Income" 40 = "40 Sample Child Income" 50 = "50 Paradata" ; VALUE AI006X 0 = "0 No" 1 = "1 Yes" ; run; /* data step to load ASCII file into a SAS dataset */ data NHIS.&adultincds; infile ASCIIDAT pad; /* define variable lengths */ length /* IDN LENGTHS */ RECTYPE 8 HHX $ 7 IMPNUM 8 /* INC LENGTHS */ FAMINCTC_A 8 POVRATTC_A 8 INCGRP_A 8 RATCAT_A 8 IMPINCFLG_A $ 5 INCTCFLG_A 8 ; /* input the data from the ASCII file */ input /* IDN LOCATIONS */ RECTYPE 1 - 2 HHX $ 3 - 9 IMPNUM 10 - 11 /* INC LOCATIONS */ FAMINCTC_A 12 - 17 POVRATTC_A 18 - 22 .2 INCGRP_A 23 - 23 RATCAT_A 24 - 25 IMPINCFLG_A $ 26 - 30 INCTCFLG_A 31 - 31 ; /* set variable labels */ label /* IDN LABELS */ RECTYPE = "Record type" HHX = "Randomly assigned household number unique to a household" IMPNUM = "Imputation number" /* INC LABELS */ FAMINCTC_A = "Sample adult family income (top-coded)" POVRATTC_A = "SA family poverty ratio (top-coded)" INCGRP_A = "Sample adult family income (grouped)" RATCAT_A = "Ratio of family income to poverty threshold for SA's family" IMPINCFLG_A = "Imputed SA family income imputation flag" INCTCFLG_A = "Sample adult family income top-code flag" ; /* Associate variables with format values. Put asterisk(*) before word "format" in the next statement to prevent format associations being stored with datatset. */ format /* IDN FORMAT ASSOCIATIONS */ RECTYPE AI005X. /* INC FORMAT ASSOCIATIONS */ FAMINCTC_A AI001X. INCGRP_A AI003X. RATCAT_A AI004X. IMPINCFLG_A $AI002X. INCTCFLG_A AI006X. ; run; /* You can edit after this line before the generate proc contents program. */ /*-------------------------------------------------------------------------*/ /* generate contents and some frequencies */ proc contents DATA=NHIS.&adultincds; TITLE1 'Contents of the 2019 NHIS Sample Adult Imputed Income file'; run; proc freq data=NHIS.&adultincds notitle; tables rectype/list missing; title1 'Frequency report for NHIS Sample Adult Imputed Income file'; title2 '(unweighted)'; run;