Hi! I love the example vignette that enables the ddi codebook to be downloaded for a cps extract.
Do you know if/when it will be possible to do this same thing for health survey extracts? I tried using the vignette here, but even that didn’t work because the “read_ipums_ddi” function only takes an .xml input and there’s no way currently to download NHIS extracts as .xml files:
IPUMS NHIS Ex. 1 for R
You are correct that the read_ipums_ddi() function only takes an .xml input. This function is meant to ingest the DDI codebook, which is available for download on your extract page as an .xml file.
The instructions under the heading Getting the data into your statistics software package from the exercise you link to notes that you should download both the data file (in .dat format) and the DDI codebook (in .xml format). To download the DDI codebook, right click on the DDI link to the right of the corresponding data extract and choose “Save link as…”. You can then select the codebook to be saved as an .xml file by selecting this option next to “Save as type”. Save both the .dat and .xml files to the same folder. The read_ipums_ddi() function should then use the .xml codebook while the read_ipums_micro() will load the corresponding .dat file with the same name as the codebook.
ddi ← read_ipums_ddi(“nhis_#####.xml”)
Note: Replace ##### with your extract number (e.g. 00001).
data ← read_ipums_micro(ddi)
1 Like
Thanks so much for this reply! Didn’t realize I could just download the xml ddi from the extract page.
The first bit of code worked for importing the ddi but hte second function (read_ipums_micro) did not; I got the following error:
Error in custom_check_file_exists()
:
! Could not find file C:/Users/AE43/OneDrive - CDC/GitHub/nhis-data/nhis_00003.dat
.
Use data_file
to specify the path to the data file associated with the provided ddi
.
Run rlang::last_trace()
to see where the error occurred.
^it may just be related to my workflow setup so I’ll troubleshoot and report back what I find.
*ah, I think I didn’t upload the .dat file in the correct place - will try that and see if it resolves
Yes, that solved the problem. I’ll proceed by manually downloading the .xml for NHIS extracts and loading it that way. Thank you!
1 Like