************FEB 21. GRAPHING IN STATA*********** cd "C:\Users\Aki\Documents\stata" log using feb21.log, replace **using preserve and restore commands sysuse auto, clear su preserve drop if weight<3000 su restore su //after running restore, you are brought to the line (point) before preserve was run. your changes to the data file will be restored. ***SAVING DATA**** drop t* save auto2.dta, replace //don't re-write or save changes to your original dataset. //to save a new dataset, can go to File menu: Save as: give a name and location *****APPEND AND MERGE****** **combining multiple data sets into one **append is userful for constructing panel data **append is good when there are different observations (individuals, countries, etc.) but same variables use append1 use append2 browse //to combine these two files, use append append using append1 //OR: go to Data menu - Combine datasets - Append datasets - select the second dataset ***merging two files: the same observations, different variables use autosize use autoexpense, clear merge 1:1 make using "C:\Users\Aki\Documents\stata\autosize.dta" ***GRAPHING IN STATA*********** help graph ***scatterplot sysuse auto, clear graph twoway scatter price mpg graph twoway scatter weight mpg graph twoway (scatter price mpg) (scatter weight mpg) **graphs can be combined this way into one only if one axis is the same graph twoway (scatter price mpg if foreign==1) (scatter price mpg if foreign==0) graph save test graph use test ***bar graphs and dot charts **vertical and horizontal bars are especially good for categorical data **and they are an effective way to vizualize frequency differences or mean differences between groups and categories graph bar (count), over (rep78) graph bar (count), over (rep78) over (foreign) graph bar (count) if price > 5000, over(rep78) over(foreign)