I have a dataset similar to census.dta. I'd like to save the variable labels (for, in this case, region) to a local and then use them in a loop. I know with this example, it's quicker to do something else, like bys region: summarize pop or tabstat pop, by(region)but I'm just using a simple example to try to figure this problem out.
I can't get the code below to work - I keep getting this error: invalid '"N Cntrl'.
Any ideas or advice would be so helpful.
Thanks,
Erika
I can't get the code below to work - I keep getting this error: invalid '"N Cntrl'.
Code:
sysuse census labelsof region local regionlab = `r(labels)' foreach r of local regionlab { keep if region == `r' summarize pop }
Thanks,
Erika
Comment