# IPUMS API - NHIS metadata

**URL:** <https://forum.ipums.org/t/ipums-api-nhis-metadata/6499>\
**Category:** IPUMS API\
**Created:** [April 22, 2025, 8:45pm UTC](https://forum.ipums.org/t/ipums-api-nhis-metadata/6499 "2025-04-22T20:45:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexandra\_Ruth](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Alexandra\_Ruth](https://forum.ipums.org/u/Alexandra_Ruth)\
**Post date:** [April 22, 2025, 8:45pm UTC](https://forum.ipums.org/t/ipums-api-nhis-metadata/6499/1 "2025-04-22T20:45:41Z")

</div>

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](https://assets.ipums.org/_files/exercises/ipums-nhis-exercise-r-1.pdf)

---

<div class="post-metadata">

**Author:** ![Ivan\_Strahof](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.ipums.org/ivan_strahof/32/626_2.png) [@Ivan\_Strahof](https://forum.ipums.org/u/Ivan_Strahof)\
**Post date:** [April 23, 2025, 9:05pm UTC](https://forum.ipums.org/t/ipums-api-nhis-metadata/6499/2 "2025-04-23T21:05:59Z")

</div>

You are correct that the [read\_ipums\_ddi()](https://tech.popdata.org/ipumsr/reference/read_ipums_ddi.html) 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()](https://tech.popdata.org/ipumsr/reference/read_ipums_micro.html) 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)

 ![Screenshot 2025-04-23 150149](https://us1.discourse-cdn.com/flex019/uploads/ipums/original/2X/7/7663678f39d729927619db11cd1d1ab6c4a96a51.png)

---

<div class="post-metadata">

**Author:** ![Alexandra\_Ruth](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Alexandra\_Ruth](https://forum.ipums.org/u/Alexandra_Ruth)\
**Post date:** [April 24, 2025, 3:44pm UTC](https://forum.ipums.org/t/ipums-api-nhis-metadata/6499/3 "2025-04-24T15:44:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Alexandra\_Ruth](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Alexandra\_Ruth](https://forum.ipums.org/u/Alexandra_Ruth)\
**Post date:** [April 24, 2025, 3:45pm UTC](https://forum.ipums.org/t/ipums-api-nhis-metadata/6499/4 "2025-04-24T15:45:34Z")

</div>

\*ah, I think I didn’t upload the .dat file in the correct place - will try that and see if it resolves

---

<div class="post-metadata">

**Author:** ![Alexandra\_Ruth](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Alexandra\_Ruth](https://forum.ipums.org/u/Alexandra_Ruth)\
**Post date:** [April 24, 2025, 3:50pm UTC](https://forum.ipums.org/t/ipums-api-nhis-metadata/6499/5 "2025-04-24T15:50:33Z")

</div>

Yes, that solved the problem. I’ll proceed by manually downloading the .xml for NHIS extracts and loading it that way. Thank you!
