*** Click on the last icon above to run the all the commnads. * This do file allows you to catch-up with the class *** Setting working directory *** IMPORTANT!!! Change the path when using your own computer or your H: drive *cd "C:\Users\nt-lab\Documents" *** Starting a log file. It will record your Stata session onto a file *** you can read it using Word or notepad. *** IMPORTANT!!! Change the path when using your own computer or your H: drive *log using "C:\Users\nt-lab\Documents\mylog.log", replace * The log file will be saved on the current working directory * To see your working directory type cap log close pwd log using mylog.log, replace *Getting the *.csv sample dataset directly into Stata *From a web address insheet using "http://dss.princeton.edu/training/mydata.csv", clear *From a folder *insheet using "C:\Users\nt-lab\Documents\mydata.csv", clear *browse /*To check the data*/ ***Converting string numeric to numeric *summarize *destring, replace destring, replace ignore("," "%") *summarize *****Cleaning the data (will use the CSV file imported using insheet) ***Delete the last empty rows. ***Below "l" = "last" drop in 4543/l /*help drop*/ *help drop /*For more details*/ destring year, replace ***Renaming variables ***rename oldname newname rename countryname country rename gdppercapitapppconstant2005inter gdppc rename unemploymentfemaleoffemalelaborf unempf rename unemploymentmaleofmalelaborforce unempm rename unemploymenttotaloftotallaborfor unemp rename exportsofgoodsandservicesconstan export rename importsofgoodsandservicesconstan import rename polityoriginal polity rename polity2adjusted polity2 *****Changing the value for imports/exports to millions replace export=export/1000000 replace import=import/1000000 gen trade = import + export label variable trade "Imports + Exports" *****How many countries (or companies, families, etc.)? egen id=group(country) sort id year *browse *sum id * Fixing unemployment variables replace unemp=. if unemp==0 replace unempf=. if unempf==0 replace unempm=. if unempm==0 * Saving the file in Stata format * It is saved in the working directory * To see the working directory type pwd save mydata, replace