*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 > 1994 Moved HH data

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

SAS Program                     go to SAS Log
******************************************************************************
Attach NRPID to the 1994 Moved Household Individual-Level Data File
1. Select ONLY 1984 Individuals in the PERSONID Data File
2. Match SPERSON84 to the MOVED94 Data File

Input data: /nangrong/personid.X01
/nangrong/1994/moved94.02
*****************************************************************************;

libname in1 xport '/nangrong/personid.X01';
libname in2 xport '/nangrong/1994/moved94.02';

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

* 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 MOVED94 Data File *
------------------------------------------------;
data moved94_nrpid notin_moved94 notin_person84b;
merge sperson84(in=a)
in2.moved94(in=b);
by VILL84 HOUSE84 CEP84;

if a=1 and b=1 then output moved94_nrpid;
if a=1 and b=0 then output notin_moved94;
if a=0 and b=1 then output notin_person84b;

run;

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

proc sort data=moved94_nrpid out=smoved94_nrpid nodupkey;
by NRPID;
run;


SAS Log                     go back to SAS Program
167        *************************************************************************
168 * Attach NRPID to the 1994 Moved Household Individual-Level Data File *
169 *************************************************************************;
170
171 * 1. Select ONLY 1984 Individuals in the PERSONID Data File *
172 --------------------------------------------------------------;
173 data person84;
174 set in1.personid(keep=VILL84 HOUSE84 CEP84 NRPID);
175
176 if (HOUSE84 ne ' ');
177
178 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.78 seconds
cpu time 0.76 seconds


179
180 *** Sort PERSON84 by VILL84 HOUSE84 CEP84 ***;
181
182 proc sort data=person84 out=sperson84 nodupkey;
183 by VILL84 HOUSE84 CEP84;
184 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.37 seconds


185
186 * 2. Match SPERSON84 to the MOVED94 Data File *
187 ------------------------------------------------;
188 data moved94_nrpid notin_moved94 notin_person84b;
189 merge sperson84(in=a)
190 in4.moved94(in=b);
191 by VILL84 HOUSE84 CEP84;
192
193 if a=1 and b=1 then output moved94_nrpid;
194 if a=1 and b=0 then output notin_moved94;
195 if a=0 and b=1 then output notin_person84b;
196
197 run;

NOTE: There were 34035 observations read from the data set WORK.SPERSON84.
NOTE: There were 3187 observations read from the data set IN4.MOVED94.
NOTE: The data set WORK.MOVED94_NRPID has 3187 observations and 15 variables.
NOTE: The data set WORK.NOTIN_MOVED94 has 30848 observations and 15 variables.
NOTE: The data set WORK.NOTIN_PERSON84B has 0 observations and 15 variables.
NOTE: DATA statement used:
real time 1.29 seconds
cpu time 1.21 seconds


198
199 *** Check for Duplicates on NRPID in MOVED94_NRPID ***;
200
201 proc sort data=moved94_nrpid out=smoved94_nrpid nodupkey;
202 by NRPID;
203 run;

NOTE: 0 observations with duplicate key values were deleted.
NOTE: There were 3187 observations read from the data set WORK.MOVED94_NRPID.
NOTE: The data set WORK.SMOVED94_NRPID has 3187 observations and 15 variables.
NOTE: PROCEDURE SORT used:
real time 0.12 seconds
cpu time 0.07 seconds


  Last Modified: 02/14/2006 UNC Carolina Population Center