/* ---------------------------------------------------------------------------- The National Health Interview Survey (NHIS) 2020; Sample Adult Partial data file This program loads the NHIS sample adult partial 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. Before running this program, please: - Download the sample adult partial ASCII file to a folder called C:\NHIS2020 (on a machine running Windows) - Configure the macro variables 'nhisfolder', 'adultpartds' 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 partial 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:\nhis2020; /* name of the dataset to load into */ %let adultpartds=adultpart20; /* 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\adultpart20.dat"; /* formats for variables */ proc format library=&formatcat; VALUE AP001X 10 = "10 Sample Adult" 20 = "20 Sample Child" 30 = "30 Sample Adult Income" 40 = "40 Sample Child Income" 50 = "50 Paradata" 60 = "60 Sample Adult Longitudinal" 70 = "70 Sample Adult Partial" ; VALUE AP002X 1963-2020 = "Survey year" ; run; /* data step to load ASCII file into a SAS dataset */ data NHIS.&adultpartds; infile ASCIIDAT pad; /* define variable lengths */ length /* IDN LENGTHS */ RECTYPE 3 SRVY_YR 4 HHX_2020 $ 7 WTSA_P 8 ; /* input the data from the ASCII file */ input /* IDN LOCATIONS */ RECTYPE 1 - 2 SRVY_YR 3 - 6 HHX_2020 $ 7 - 13 WTSA_P 14 - 21 ; /* set variable labels */ label /* IDN LABELS */ RECTYPE = "Record type" SRVY_YR = "Year of the National Health Interview Survey" HHX_2020 = "Randomly assigned household number unique to a household" WTSA_P = "Final Partial weight" ; /* 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 AP001X. SRVY_YR AP002X. ; run;