Please consider the following data set: data set_1
clear
. input str8 respid byte str5 commid
respid commid
1. XY050037 XY001
2. XY050038 XY001
3. XY050050 XY002
4. XY050014 XY003
5. end
. list
+-------------------+
| respid commid |
|-------------------|
1. | XY050037 XY001 |
2. | XY050038 XY001 |
3. | XY050050 XY002 |
4. | XY050014 XY003 |
+-------------------+
. clear
. input str8 respid byte str5 commid
respid commid
1. XY050037 XY001
2. XY050038 XY001
3. XY050050 XY002
4. XY050014 XY003
5. end
. list
+-------------------+
| respid commid |
|-------------------|
1. | XY050037 XY001 |
2. | XY050038 XY001 |
3. | XY050050 XY002 |
4. | XY050014 XY003 |
+-------------------+
. clear
Now i have another data set, on the same observations, but without the commid. For eg: Data set_2:
input str5 respid
respid
1. 50037
2. 50038
3. 50050
4. 50014
5. end
. list
+--------+
| respid |
|--------|
1. | 50037 |
2. | 50038 |
3. | 50050 |
4. | 50014 |
+--------+
respid
1. 50037
2. 50038
3. 50050
4. 50014
5. end
. list
+--------+
| respid |
|--------|
1. | 50037 |
2. | 50038 |
3. | 50050 |
4. | 50014 |
+--------+
I have been looking at posts about using loops for generating ID variables but am unable to find a solution to my problem. Would greatly appreciate your help.
Thank you.
0 Response to Generating ID variables in one data set based on some observations in another data set
Post a Comment