hw4do - clear all set memory 700m set more off global...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
clear all set memory 700m set more off global cpath "D:\TA\2013fmeconometrics\CFPS" use ${cpath}\CFPS_2010_famconf.dta,clear sort pid save ${cpath}\tempCFPS_2010_famconf.dta,replace use ${cpath}\CFPS_2010_adult.dta,clear sort pid merge pid using ${cpath}\tempCFPS_2010_famconf.dta tab _merge by pid,sort:gen x=_n tab x drop x save ${cpath}\tempall.dta,replace /* _merge | Freq. Percent Cum. ------------+----------------------------------- 2 | 23,555 41.21 41.21 // 只出现在 CFPS_2010_famconf 的观测值 3 | 33,600 58.79 100.00 ------------+----------------------------------- Total | 57,155 100.00 */ * a.How many households are included in this dataset? How many individuals? * --hint: pid, fid * answer 1: use ${cpath}\tempall.dta,clear preserve xtset fid pid xtsum pid di "sample size of household =" r(n) restore * answer 2: preserve // 冻结数据, preserve-restore 之间的操作不会改变数据,避免操作失误造成数据无法
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
恢复 quietly{ drop if fid==fid[_n-1] count if fid<. } di "sample size of household =" r(N) restore *b.Tabulate the family size, for example, what is the percentage of the family * that has three household members, what is the percentage for four, * and how many have only one family member *--hint: pid fid preserve quietly{ by fid,sort:gen fsize=_N // 生成每个家户人口数量 drop if fid==fid[_n-1] // 删除家户 id 重复的观测值,使得样本中每个家户只有一个观测值 } *tablist fsize tab fsize restore *c. Tabulate the number of children in these households. * What is the percentage of the families who have no children?
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern