# Joining medication round fill to condition records

**URL:** <https://forum.ipums.org/t/joining-medication-round-fill-to-condition-records/6184>\
**Category:** General\
**Created:** [November 8, 2024, 5:01pm UTC](https://forum.ipums.org/t/joining-medication-round-fill-to-condition-records/6184 "2024-11-08T17:01:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacob\_Wittman](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@Jacob\_Wittman](https://forum.ipums.org/u/Jacob_Wittman)\
**Post date:** [November 8, 2024, 5:01pm UTC](https://forum.ipums.org/t/joining-medication-round-fill-to-condition-records/6184/1 "2024-11-08T17:01:50Z")

</div>

I am trying to follow the instructions for linking the medication round fill records with condition records for MEPS. The first step is as follows:

IPUMS MEPS staff encourage users to first either 1) summarize medication-round fill records to the medication-round level or 2) reshape medication-round fill records from long to wide so that each prescribed medicine fill associated with a given medication-round record (MEPSLINKIDM) is on the same record line. This is because multiple medication-round fill records can be associated with multiple condition records, resulting in a many-to-many merge when linking these records together.

I am attempting to do the second option. I have set up the medication-record fill data by filtering my hierarchical dataset to the RECTYPE == F in R and removed any of the columns where all the values are NA. When I do this, it removes the MEPSLINKIDM column. How then am I supposed to reshape my data from long to wide so that 'each prescribed medicine fill associated with a given medication-round record (MEPSLINKIDM) is on the same record line? " Is there something I’m missing here? It’s also unclear how I might approach the first option, since the MEPSLINKIDM column seems important for summarizing up to the medication-round level.

---

<div class="post-metadata">

**Author:** ![Isabel\_Pastoor](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.ipums.org/isabel_pastoor/32/788_2.png) [@Isabel\_Pastoor](https://forum.ipums.org/u/Isabel_Pastoor)\
**Post date:** [November 13, 2024, 8:31pm UTC](https://forum.ipums.org/t/joining-medication-round-fill-to-condition-records/6184/2 "2024-11-13T20:31:30Z")

</div>

The variable [MEPSLINKIDM](https://meps.ipums.org/meps-action/variables/MEPSLINKIDM#description_section) is a medication-round record identifier, and is only available on medication-round records (RECTYPE=M). It is not available on medication-round fill records (RECTYPE=F). Therefore, if you retain only F records and drop all blank columns, you will lose the variable MEPSLINKIDM. In a hierarchical IPUMS MEPS extract, medication-round fill records are nested beneath medication-round records. This means that medication-round fill records have associated medication-round records; the medication-round records have corresponding MEPSLINKIDM values. You will want to reshape your data such that there is one row per medication-round record, and variables describing each medication-round fill associated with that record. To do so, you can use [MEPSLINKIDF](https://meps.ipums.org/meps-action/variables/MEPSLINKIDF#description_section). MEPSLINKIDF is a medication-round record identifier, applied to medication-round fill records. Be sure to retain both F records and M records.

Note that MEPSLINKIDM is only available in samples through 2020. When using samples from 2021 and later, you should link medication-round fill records directly to the condition records, using the variables MEPSLINKIDF, [MEPSEVNTIDJ](https://meps.ipums.org/meps-action/variables/MEPSEVNTIDJ#description_section), and [YEAR](https://meps.ipums.org/meps-action/variables/YEAR#description_section).
