************************************ ************************************ ***SOCI 420: ADVANCED METHODS OF SOCIAL RESEARCH ***APPEND DIFFERENT YEARS OF GENERAL SOCIAL SURVEY ************************************ ************************************ ************************************ ***CLEAR MEMORY ************************************ clear all ************************************ ***CREATE SHORTCUTS AND LOG FILE ************************************ ***Shortcut for folders global codes = "H:\course\codes" global data = "H:\course\data" global output = "H:\course\output" ***Start saving results window log using "$codes\Stata_append.log", replace text ************************************ ***OPENING COMMANDS ************************************ ***Tell Stata to not pause for "more" messages set more off ***Change directory cd "$data" ************************************ ***APPEND DIFFERENT YEARS ************************************ ***Open 2022 GSS use "GSS2022.dta", clear ***Append 2014 GSS append using "GSS2014.dta" ***Append 2004 GSS append using "GSS2004.dta" ************************************ ***NEW WEIGHT VARIABLE ************************************ gen weightfinal=. ***Pre-2021: Use wtssall replace weightfinal=wtssall if year>=1972 & year<=2018 ***2021 and beyond: Use wtssnrps replace weightfinal=wtssnrps if year>=2021 & year<=2022 ***Verify weight (it should have no missing cases) count if weightfinal==. ************************************ ***DESCRIPTIVE STATISTICS ************************************ ***Frequency by year tab year tab year [aweight=weightfinal] ***Frequency by sex and year tab sex year, col tab sex year [aweight=weightfinal], col ************************************ ***CLOSING COMMANDS ************************************ ***Save data save "Stata_append.dta", replace ***Save log log close