Joining medication round fill to condition records

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.

The variable MEPSLINKIDM 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. 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, and YEAR.