All Posts
Rules
Sharing
Questions
Information
Inspiration
Comments for Papers
Comments for Topics

[Questions] CHIP2007和CHIP2008合并面板数据

Comment Time: 2014/8/16 4:53:11 |  Recent Response Time: 2022/10/17 18:20:45 |  Read Times: 6687 |  Following: 4
Author: 412293072 |  Tags/Keywords:

 您好,

之前发邮件询问是否可以将这两组数据合并成面板数据,得到肯定答复。但有一个问题是,2007的数据hhcode是double type 而2008数据hhcode却是string,即使排除带新加入的家庭,两组样本也很难合并。

请问如果可以合并,又该如何做呢?谢谢

  Choose the Page Number:   The Number of Posts per Page:
[Post ID: 140] (Reply to the Post 139 ) 回复问题
Reply Time: 2014/8/16 10:55:23 |  Recent Update Time: 2014/8/16 10:55:23 | 
Author: struggle12 |  Tags/Keywords: 回复

 建议将hhcode转换成string格式以后再进行合并。建议按照如下程序处理CHIP2007的家户ID。

 

use `filename',clear


tostring count, g(count_str)

gen count_str_t1 = 6 - length(count_str)

gen count_str_t2 = 10^count_str_t1

tostring count_str_t2,replace

replace count_str = count_str_t2 + count_str

replace count_str = substr(count_str,2,7)

drop count_str_t1 count_str_t2


tostring street, g(street_str)

gen street_str_t1 = 3 - length(street_str)

gen street_str_t2 = 10^street_str_t1

tostring street_str_t2,replace

replace street_str = street_str_t2 + street_str

replace street_str = substr(street_str,2,7)

drop street_str_t1 street_str_t2


tostring group, g(group_str)

gen group_str_t1 = 3 - length(group_str)

gen group_str_t2 = 10^group_str_t1

tostring group_str_t2,replace

replace group_str = group_str_t2 + group_str

replace group_str = substr(group_str,2,7)

drop group_str_t1 group_str_t2


tostring hous, g(hous_str)

gen hous_str_t1 = 5 - length(hous_str)

gen hous_str_t2 = 10^hous_str_t1

tostring hous_str_t2,replace

replace hous_str = hous_str_t2 + hous_str

replace hous_str = substr(hous_str,2,7)

drop hous_str_t1 hous_str_t2


capture replace orgn_code2 = count_str + street_str + group_str + hous_str

if _rc != 0 {

    gen orgn_code2 = count_str + street_str + group_str + hous_str

}

drop count_str street_str group_str hous_str orgn_code

sort orgn_code2

[Post ID: 178] (Reply to the Post 140 ) 关于合并后的问题
Reply Time: 2015/3/12 20:33:21 |  Recent Update Time: 2022/10/17 18:20:45 | 
Author: yinbj |  Tags/Keywords:
原来的数据中是没有orgn_code2这个标签的吧,应该换成hhcode(原问卷中的家庭ID),但是这样转换之后得到的新的家庭ID和2008年的家庭ID没有能匹配的呀?能否请教你们在转换后匹配时得到的配对家庭对数有多少?
[Post ID: 179] (Reply to the Post 178 ) 回复问题
Reply Time: 2015/3/12 20:35:45 |  Recent Update Time: 2015/3/12 20:35:45 | 
Author: struggle12 |  Tags/Keywords: 回复

 上面那个程序就是生成orgn_code2的

[Post ID: 899] (Reply to the Post 178 ) 我试了,城镇数据匹配后有3835个家庭样本
Reply Time: 2022/10/17 18:20:45 |  Recent Update Time: 2022/10/17 18:20:45 | 
Author: 15656282718 |  Tags/Keywords:

我试了,城镇数据匹配后有3835个家庭样本

Projects of CCEHD