*Programming Examples
*1984 data
*1994 data
*1994 Moved HH data
*1994 Migrant data
*2000 data
* 2000 Moved HH data
*2000 Migrant data
 
You are here: Home > Data > Identifiers > Person Identifier > Programming Examples > 2000 Moved HH data

Add the Person Identifier (NRPID) to the 2000 Moved Household data

SAS Program                     go to SAS Log
******************************************************************************
Attach NRPID to the 2000 Moved Household Individual-Level Data File
1. Select ONLY 2000 Individuals in the PERSONID Data File
2. Match SPERSON00 to the MOVED00 Data File

Input data: /nangrong/personid.X01
/nangrong/2000/moved00.03
*****************************************************************************;

libname in1 xport '/nangrong/personid.X01';
libname in2 xport '/nangrong/2000/moved00.03';

*************************************************************************
* Attach NRPID to the 2000 Moved Household Individual-Level Data File *
*************************************************************************;

* 1. Select ONLY 2000 Individuals in the PERSONID Data File *
--------------------------------------------------------------;
data person00;
set in1.personid(keep=HHID00 CEP00 NRPID);

if (HHID00 ne ' ');

run;

*** Sort WORK.PERSON00 by HHID00 CEP00 ***;

proc sort data=person00 out=sperson00 nodupkey;
by HHID00 CEP00;
run;

* 2. Match SPERSON00 to the MOVED00 Data File *
------------------------------------------------;
data moved00_nrpid notin_moved00 notin_person00b;
merge sperson00(in=a)
in7.moved00(in=b);
by HHID00 CEP00;

if a=1 and b=1 then output moved00_nrpid;
if a=1 and b=0 then output notin_moved00;
if a=0 and b=1 then output notin_person00b;

run;

*** Check for Duplicates on NRPID in MOVED00_NRPID ***;

proc sort data=moved00_nrpid out=smoved00_nrpid nodupkey;
by NRPID;
run;



SAS Log                     go back to SAS Program
336        *************************************************************************
337 * Attach NRPID to the 2000 Moved Household Individual-Level Data File *
338 *************************************************************************;
339
340 * 1. Select ONLY 2000 Individuals in the PERSONID Data File *
341 --------------------------------------------------------------;
342 data person00;
343 set in1.personid(keep=HHID00 CEP00 NRPID);
344
345 if (HHID00 ne ' ');
346
347 run;

NOTE: There were 57416 observations read from the data set IN1.PERSONID.
NOTE: The data set WORK.PERSON00 has 53093 observations and 3 variables.
NOTE: DATA statement used:
real time 0.84 seconds
cpu time 0.81 seconds


348
349 *** Sort PERSON00 by HHID00 CEP00 ***;
350
351 proc sort data=person00 out=sperson00 nodupkey;
352 by HHID00 CEP00;
353 run;

NOTE: 0 observations with duplicate key values were deleted.
NOTE: There were 53093 observations read from the data set WORK.PERSON00.
NOTE: The data set WORK.SPERSON00 has 53093 observations and 3 variables.
NOTE: PROCEDURE SORT used:
real time 0.68 seconds
cpu time 0.65 seconds


354
355 * 2. Match SPERSON00 to the MOVED00 Data File *
356 ------------------------------------------------;
357 data moved00_nrpid notin_moved00 notin_person00b;
358 merge sperson00(in=a)
359 in7.moved00(in=b);
360 by HHID00 CEP00;
361
362 if a=1 and b=1 then output moved00_nrpid;
363 if a=1 and b=0 then output notin_moved00;
364 if a=0 and b=1 then output notin_person00b;
365
366 run;

NOTE: There were 53093 observations read from the data set WORK.SPERSON00.
NOTE: There were 3680 observations read from the data set IN7.MOVED00.
NOTE: The data set WORK.MOVED00_NRPID has 3680 observations and 47 variables.
NOTE: The data set WORK.NOTIN_MOVED00 has 49413 observations and 47 variables.
NOTE: The data set WORK.NOTIN_PERSON00B has 0 observations and 47 variables.
NOTE: DATA statement used:
real time 3.48 seconds
cpu time 3.33 seconds


367
368 *** Check for Duplicates on NRPID in MOVED00_NRPID ***;
369
370 proc sort data=moved00_nrpid out=smoved00_nrpid nodupkey;
371 by NRPID;
372 run;

NOTE: 0 observations with duplicate key values were deleted.
NOTE: There were 3680 observations read from the data set WORK.MOVED00_NRPID.
NOTE: The data set WORK.SMOVED00_NRPID has 3680 observations and 47 variables.
NOTE: PROCEDURE SORT used:
real time 0.23 seconds
cpu time 0.13 seconds


  Last Modified: 02/16/2005 UNC Carolina Population Center