# Tutorial: Matching Cohabiting Partners to Their Characteristics in the NLSY97

## Step 3: Find the partner id for the first partner

To find the id for the first partner, you will look at the element of the MAR_PARTNER_LINK array for the first element that contains a partner id. For instance, for respondent id=7525, the first partner id (501) is found in MAR_PARTNER_LINK_02_01 (February 2001).

In Round 10, the MAR_PARTNER_LINK array is available for the months April 1994 to May 2007.

Using SAS, sample code that is provided below shows how to find the id of the first partner. The code first creates an array with all the MAR_PARTNER_LINK variables. It then loops through the array until SAS finds the first element in which the array contains a partner id. When the array first contains a value for partner id, the value of MAR_PARTNER_LINK is the id for the respondent's first partner. I made two new variables, called (1) firstpid, that takes the value of the 1st partner id and (2) month1cohab, that indicates the number of the element in array when the respondent first cohabitated.

do k=1 to 163;
if MAR_PARTNER_LINK(k) gt 0 and firstpid eq . then do; month1cohab=k; firstpid=MAR_PARTNER_LINK(k);
end;

## Step 4: Split 1st partner id (firstpid) into round number and loop number

The values of the MAR_PARTNER_LINK variables are the round followed by the partner number within that round. For instance, for sample member 7525, the MAR_PARTNER_LINK value in February of 2001 is 501, indicating that this partner is first listed in Round 5. You'll need to look in the partner roster in this round. To do this more efficiently, you need to split the partner id into its two components' round and number within that round.

In SAS, code that lets you split the two pieces of information can be:

withinrnd=mod(firstpid,100); /* this command yields the remainder from dividing firstpid by 100*/
round=(firstpid-withinrnd)/100;