Hi folks. First time poster, relatively new-ish stata user. I'm trying to create multiple bar graphs for race and gender percentages based on one of my variables (AcademicRankMajor) using a loop. The loop works perfectly...until I try to add a command to save the graphs. I've tried everything I can think of to get it to work; I've tried omitting the continuation, using the "graph export" command instead, using the name/ replace command. None of these solutions work. When I run this command specifically, I get an error message that reads "invalid 'replace'". Here's my code:
levelsof(AcademicRankMajor), local(levels)
foreach level of local levels {
catplot Gender Ethnicity if AcademicRankMajor=="`level'", title("Gender and Ethnicity by `level'") ///
style(compact) ///
stack asyvars percent (AcademicRankMajor) ///
graph save "EthGen by `level'" , replace
}
I'm sure the solution is simple-ish, but I've exhausted my own working knowledge here. Thanks!
levelsof(AcademicRankMajor), local(levels)
foreach level of local levels {
catplot Gender Ethnicity if AcademicRankMajor=="`level'", title("Gender and Ethnicity by `level'") ///
style(compact) ///
stack asyvars percent (AcademicRankMajor) ///
graph save "EthGen by `level'" , replace
}
I'm sure the solution is simple-ish, but I've exhausted my own working knowledge here. Thanks!
Comment