day3prlm - 1/26/12 PADP 8130: Linear Models Math...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1/26/12 PADP 8130: Linear Models Math Review PRACTICE Angela Fer:g, Ph.D. Ge?ng Stata output into Excel •  If it is from sum or tab, highlight the table and copy using the shiL key •  If it is a regression, use outreg2 –  Open up a do file –  Name it, put top lines in, open dataset –  Run regression: reg faminc educhd! –  Put in outreg2 command: !outreg2 using regs1, excel replace! –  Run next regression: reg –  Put in outreg2 command faminc educhd agehd !outreg2 using regs1, excel! –  Within excel, open up regs1.xml ! 1 1/26/12 Some useful data management commands: append, merge & reshape •  Append – combine 2 data sets by stacking the observa:ons; it just increases the sample size •  Merge – combine 2 data sets by increasing the variables observed on each observa:on; it increases what you know about each observa:on –  So, if you made your beau:ful datafile for your research project and it took hours, and then you realize that you are missing one variable, merge can fix it. •  Just get the addi:onal variable needed in a separate data file. •  Merge it with the new data file. Reshape Reshape: converts data from long to wide, or vice versa e.g. one observa:on has informa:on on husbands and wives, but you want husbands and wives to each be their own observa:on – you need to reshape from wide to long id person Wagehd id Wagehd wagewf 1 1 100000 1 100000 10000 1 2 10000 2 35000 15000 2 1 35000 2 2 15000 2 1/26/12 Try it out •  Go to the psid data center and find the wage data for the head and wife – make the data set •  Merge it with day2.dta Use day2.dta Sort fid Save day2.dta Use wage.dta Sort fid Save wage.dta clear Use day2.dta Merge fid using wage.dta Save day3.dta, replace Then reshape •  Reshape long so husbands and wives are separate observa:ons Use day3.dta Reshape long wage, i(fid) j(person) Save day3r.dta, replace Make sure beginning of variable name is same for both husband and wife. Fid is the unique iden:fier in the wide format. Person is a new variable that will be created to iden:fy the husbands vs. the wives for each fid. 3 ...
View Full Document

This note was uploaded on 03/28/2012 for the course PADP 8130 taught by Professor Fertig during the Spring '12 term at LSU.

Ask a homework question - tutors are online