I am working with a dataset with merged data from 2 survey rounds (2005 & 20011).
The first column/variable "SURVEY" represents whether the observation is from survey 1 or 2
The second column/variable "HHBASE" represents the unique Household Base ID which remains unchanged for the two surveys
The third column/variable "PBASE" represents the unique Person Base ID which remains unchanged for the two surveys
I would like to create a new id variable using HHBASE and PBASE in such a way that the numbers are not added but instead "combined". For example:
HHBASE = 100
PBASE = 1
New var = 1001
Below, I am pasting a sample of the data that I need help with.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int SURVEY double HHBASE int PBASE 1 1010201010 1 1 1010201010 2 1 1010201010 5 1 1010201010 6 1 1010201010 3 1 1010201020 15 2 1010201020 4 2 1010201020 14 2 1010201020 9 2 1010201020 5 2 1010201020 6 1 1010201020 14 2 1010201020 13 1 1010201020 11 2 1010201020 10 1 1010201020 6 2 1010201020 7 1 1010201020 7 1 1010201020 8 2 1010201020 1 1 1010201020 5 2 1010201020 11 1 1010201020 4 2 1010201020 12 1 1010201020 10 2 1010201020 8 2 1010201020 3 2 1010201020 15 1 1010201020 1 1 1010201020 12 1 1010201020 3 1 1010201020 13 1 1010201020 9 1 1010201030 6 2 1010201030 3 1 1010201030 1 2 1010201030 2 1 1010201030 7 2 1010201030 1 2 1010201030 5 2 1010201030 7 2 1010201030 4 1 1010201030 3 1 1010201030 5 2 1010201030 6 1 1010201030 2 1 1010201030 4 2 1010201040 2 1 1010201040 5 2 1010201040 3 2 1010201040 1 1 1010201040 4 1 1010201040 1 2 1010201040 5 2 1010201040 4 1 1010201040 3 1 1010201040 2 1 1010201050 6 2 1010201050 8 2 1010201050 6 1 1010201050 2 1 1010201050 10 1 1010201050 9 1 1010201050 7 2 1010201050 2 1 1010201050 8 2 1010201050 9 1 1010201050 3 2 1010201050 10 2 1010201050 3 2 1010201050 7 1 1010201060 12 2 1010201060 1 1 1010201060 15 2 1010201060 13 2 1010201060 12 2 1010201060 15 1 1010201060 14 1 1010201060 1 2 1010201060 14 1 1010201060 13 1 1010201070 3 2 1010201070 1 1 1010201070 1 2 1010201070 2 2 1010201070 9 2 1010201070 7 1 1010201070 7 2 1010201070 6 2 1010201070 8 1 1010201070 9 1 1010201070 4 1 1010201070 6 2 1010201070 4 1 1010201070 2 1 1010201070 8 2 1010201070 3 2 1010201080 3 2 1010201080 6 1 1010201080 1 end label values SURVEY SURVEY label def SURVEY 1 "IHDS1 1", modify label def SURVEY 2 "IHDS2 2", modify
Thanks for your help!
Regards,
Abhishek Patil
0 Response to How to combine two variables to create a new one?
Post a Comment