*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 > 1984 data

Add the Person Identifier (NRPID) to the 1984 data

SAS Program                     go to SAS Log
******************************************************************************
Attach NRPID to the 1984 Individual-Level Data File (indiv84)
1. Select ONLY 1984 Individuals in the PERSONID Data File
2. Match SPERSON84 to the INDIV84 Data File

Input data: /nangrong/personid.X01
/nangrong/1984/indiv84.02
*****************************************************************************;

libname in1 xport '/nangrong/personid.X01';
libname in2 xport '/nangrong/1984/indiv84.02';

*******************************************************************
* Attach NRPID to the 1984 Individual-Level Data File (indiv84) *
*******************************************************************;

* 1. Select ONLY 1984 Individuals in the PERSONID Data File *
--------------------------------------------------------------;
data person84;
set in1.personid(keep=VILL84 HOUSE84 CEP84 NRPID);

if (HOUSE84 ne ' ');

run;

*** Sort PERSON84 by VILL84 HOUSE84 CEP84 ***;

proc sort data=person84 out=sperson84 nodupkey;
by VILL84 HOUSE84 CEP84;
run;

* 2. Match SPERSON84 to the INDIV84 Data File *
------------------------------------------------;
data indiv84_nrpid notin_indiv84 notin_person84a;
merge sperson84(in=a)
in2.indiv84(in=b);
by VILL84 HOUSE84 CEP84;

if a=1 and b=1 then output indiv84_nrpid;
if a=1 and b=0 then output notin_indiv84;
if a=0 and b=1 then output notin_person84a;

run;

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

proc sort data=indiv84_nrpid out=sindiv84_nrpid nodupkey;
by NRPID;
run;


SAS Log                     go back to SAS Program
62         
63 *******************************************************************
64 * Attach NRPID to the 1984 Individual-Level Data File (indiv84) *
65 *******************************************************************;
66
67 * 1. Select ONLY 1984 Individuals in the PERSONID Data File *
68 --------------------------------------------------------------;
69 data person84;
70 set in1.personid(keep=VILL84 HOUSE84 CEP84 NRPID);
71
72 if (HOUSE84 ne ' ');
73
74 run;

NOTE: There were 57416 observations read from the data set IN1.PERSONID.
NOTE: The data set WORK.PERSON84 has 34035 observations and 4 variables.
NOTE: DATA statement used:
real time 0.83 seconds
cpu time 0.80 seconds


75
76 *** Sort PERSON84 by VILL84 HOUSE84 CEP84 ***;
77
78 proc sort data=person84 out=sperson84 nodupkey;
79 by VILL84 HOUSE84 CEP84;
80 run;

NOTE: 0 observations with duplicate key values were deleted.
NOTE: There were 34035 observations read from the data set WORK.PERSON84.
NOTE: The data set WORK.SPERSON84 has 34035 observations and 4 variables.
NOTE: PROCEDURE SORT used:
real time 0.40 seconds
cpu time 0.38 seconds


81
82 * 2. Match SPERSON84 to the INDIV84 Data File *
83 ------------------------------------------------;
84 data indiv84_nrpid notin_indiv84 notin_person84a;
85 merge sperson84(in=a)
86 in2.indiv84(in=b);
87 by VILL84 HOUSE84 CEP84;
88
89 if a=1 and b=1 then output indiv84_nrpid;
90 if a=1 and b=0 then output notin_indiv84;
91 if a=0 and b=1 then output notin_person84a;
92
93 run;

NOTE: There were 34035 observations read from the data set WORK.SPERSON84.
NOTE: There were 34035 observations read from the data set IN2.INDIV84.
NOTE: The data set WORK.INDIV84_NRPID has 34035 observations and 26 variables.
NOTE: The data set WORK.NOTIN_INDIV84 has 0 observations and 26 variables.
NOTE: The data set WORK.NOTIN_PERSON84A has 0 observations and 26 variables.
NOTE: DATA statement used:
real time 3.18 seconds
cpu time 3.07 seconds


94
95 *** Check for Duplicates on NRPID in INDIV84_NRPID ***;
96
97 proc sort data=indiv84_nrpid out=sindiv84_nrpid nodupkey;
98 by NRPID;
99 run;

NOTE: 0 observations with duplicate key values were deleted.
NOTE: There were 34035 observations read from the data set WORK.INDIV84_NRPID.
NOTE: The data set WORK.SINDIV84_NRPID has 34035 observations and 26 variables.
NOTE: PROCEDURE SORT used:
real time 1.10 seconds
cpu time 0.79 seconds



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