# CPS monthly survey linkage to create panel data

**URL:** <https://forum.ipums.org/t/cps-monthly-survey-linkage-to-create-panel-data/4200>\
**Category:** CPS\
**Created:** [June 27, 2021, 3:46pm UTC](https://forum.ipums.org/t/cps-monthly-survey-linkage-to-create-panel-data/4200 "2021-06-27T15:46:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tariq\_Khasiri](https://avatars.discourse-cdn.com/v4/letter/t/6de8d8/32.png) [@Tariq\_Khasiri](https://forum.ipums.org/u/Tariq_Khasiri)\
**Post date:** [June 27, 2021, 3:46pm UTC](https://forum.ipums.org/t/cps-monthly-survey-linkage-to-create-panel-data/4200/1 "2021-06-27T15:46:25Z")

</div>

Hello IPUMS community,

I have been working with the CPS ASEC but lately trying to get my hands on the monthly sample. After going through a handful of posts on IPUMS forum, I was pretty confused before I come across this post - which was very clear about how I should approach the monthly data.

> [@Linking basic months data across four consecutive months](https://forum.ipums.org/t/linking-basic-months-data-across-four-consecutive-months/3937):
>
> Hello. I am trying to link basic monthly CPS data across four consecutive months and check how good my matches are by looking at CPSIDP linkages with AGE, SEX, and RACE using Stata. My ultimate goal is to calculate the quarterly transition rate of individuals from one industry to another industry from January 2014 to April 2015. I am very new to CPS, and I wanted to make sure that my understanding of linking monthly data and verifying the matches is correct. In CPSIDP, it has information on uni…

In spite of clear guidelines, I’m still trying to get hold of the concept of merging since I am not sure what will give me the best outcome to create the panel. I’m not sure should I create the 8 month panel ( given in the first exercise of stata workshop in 2018 ) or should I just create one year panel by linking CPSIDP. And also there is a concern of validation by age , race and sex.

My main purpose is to see how a person changes job and how it affects the wage in few selective states.

My sample is from 1995-2005. But, I haven’t been able to code it properly to come up with the matching. I think it would be best to see what’s the maximum time CPSIDP shows up within 16 months of his first interview - which goes perfectly with my research interest.

In the stata exercise 2 of workshop 2018 , it also shows me the code to track what’s the maximum time a unique CPSIDP shows up ( even after 1 year or 2 year later given the interview takes place two years before in December month ).

Since, I’m. a beginner with the monthly sample , therefore wanted ti make sure I’m starting off to the right direction with my concept.

Any helpful suggestion or additional help with coding will most definitely help !

---

<div class="post-metadata">

**Author:** ![Tariq\_Khasiri](https://avatars.discourse-cdn.com/v4/letter/t/6de8d8/32.png) [@Tariq\_Khasiri](https://forum.ipums.org/u/Tariq_Khasiri)\
**Post date:** [June 28, 2021, 12:37am UTC](https://forum.ipums.org/t/cps-monthly-survey-linkage-to-create-panel-data/4200/2 "2021-06-28T00:37:15Z")

</div>

To be more precise about my research interest , I think it would be more suitable if I can keep track of a unique CPSIDP till it finishes the 16 month cycle of the 4-8-4 formation. So, after going through and reading a few more relevant posts and very helpful feedback of IPUMS community I came with the following command to create the 16 month panel ( which I adapted a little from the command given in this post : [FAILURE: Linking to the Same Calendar Month across Two Consecutive Years from JULY 1994 to AUGUST 1995](https://forum.ipums.org/t/failure-linking-to-the-same-calendar-month-across-two-consecutive-years-from-july-1994-to-august-1995/2721)

gen time = ym(year, month)

forvalues t=372(1)680{

keep if (time== `t' & mish==8)|(time==` t’-16 & mish==4)

order cpsidp year month

sort cpsidp year month

by cpsidp: gen obs=\_N

by cpsidp: drop if obs!=2

In the above command , I just changed the third line from the one provided in the post by putting time==` t’-16 instead of time==` t’-12 , since I’m trying to link observation throughout 16 months instead of making it a one year panel data.

And, the command provided in the post is for finding EARNWEEK , whereas in my case the outcome is INCWAGE and UHRSWEEK1. Are using the mish==8 and mish==4 correct choice of values given that I’m creating a 16 month panel data whereas the post maker was creating one year panel data ?

I hope I’m making sense. And, if my post goes a little off track because of not holding a good grip over the basic concept - any helpful suggestion or advice is very much welcome from respected IPUMS community !

---

<div class="post-metadata">

**Author:** ![Tariq\_Khasiri](https://avatars.discourse-cdn.com/v4/letter/t/6de8d8/32.png) [@Tariq\_Khasiri](https://forum.ipums.org/u/Tariq_Khasiri)\
**Post date:** [June 28, 2021, 6:07pm UTC](https://forum.ipums.org/t/cps-monthly-survey-linkage-to-create-panel-data/4200/3 "2021-06-28T18:07:50Z")

</div>

My gut feeling is that , since I’d like to track that unique id from beginning , so my desired variables should be : mish==8 and mish==1.

---

<div class="post-metadata">

**Author:** ![Matthew\_Bombyk](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@Matthew\_Bombyk](https://forum.ipums.org/u/Matthew_Bombyk)\
**Post date:** [September 2, 2021, 9:32pm UTC](https://forum.ipums.org/t/cps-monthly-survey-linkage-to-create-panel-data/4200/4 "2021-09-02T21:32:11Z")

</div>

We’ve already corresponded about this by email, but I wanted to also reply to your post in case others have a similar question. While we don’t generally provide individual code review, since you’ve modified code provided by IPUMS CPS I’ll give the following advice:

From what I read, this is what your code is doing:

> gen time = ym(year, month)  
> forvalues t=372(1)680{  
> keep if (time== `t' & mish==8)|(time==` t’-16 & mish==4)  
> order cpsidp year month  
> sort cpsidp year month  
> by cpsidp: gen obs=\_N  
> by cpsidp: drop if obs!=2

1. Loop through values of **time** from 2005 to 2020. Since you used ym(), **time** actually gives the number of months since January 1960. So your loop won’t cover any of the months of the CPS.

2. The **keep** command as written will drop out all the observations in the data. After the first loop, it will keep only those with time values of 2005 or 1993 (2005 minus 12). After the second loop, those records will also be deleted.

3. Generate **obs** , which gives the number of times a given cpsidp appears in the data

4. Drop all individuals who appear in the data only 1 time. (I’m assuming you’re using only ASEC data for this. In that case this will keep anyone who has two years of ASEC, which is what you want. If using basic monthly data, this will drop anyone who doesn’t appear exactly twice in the data.)

Overall, you have at least two errors in the code which will result in dropping all the observations.

Here are some other resources that may be helpful in understanding how to use the CPS longitudinally:

- [IPUMS page on linking the CPS](https://cps.ipums.org/cps/cps_linking_documentation.shtml) and the CPS rotation pattern
- [coding exercises](https://www.ipums.org/support/exercises) for IPUMS datasets
