I'm using the Collapse command in Stata to aggregate a series of numbers by different categories. The data is a series of individual hourly regression estimates (hr1-h24) as well as a few other variables. The objective is to create a mean value for each hour, multiply by a population count, and then sum to different category levels. The code looks like this: collapse (mean) p10_hr1-p10_hr24, by(date cat1 subcat2 subcat3)
joinby date cat1 subcat2 subcat3 using popcnt.dta
reshape long p10_hr popcnt, i(date cat1 subcat2 subcat3) j(hour)
replace p10_hr = p10_hr * population
reshape wide p10_hr, i(date cat1 subcat2 subcat3) j(hour)
collapse (sum) p10_hr1-p10_hr24, by(date cat1 subcat2 subcat3)
It's at this point that I get an error message:
error:
p10_hr1 = (mean) p10_hr1
p10_hr1 = (sum) p10_hr1
name conflict
r(198);
Does anyone know what is going on here?
I've also posted this question on Reddit:
https://www.reddit.com/r/stata/comme...20Amazon%20SES
Related Posts with Collapse command error message that has me stumped
Lag independent variable in fixed effects regression using repeated cross section dataHello Statalist, I'm currently analyzing repeated cross-section data (different individuals were su…
How to find the value of a variable using condition on another variable?Hi Statalist users, I have a dataset of which I am posting a snippet with relevant variables (age, …
considering inter eyes correlation in spearman analysis(mixed model)Hi I am working on retinal thickness of 68 eyes measured by 2 devices. I calculated the spearman co…
How to avoid duplication in observations for variables that exist in multiple waves of panel dataHi Statalist. Using panel dataset with five waves, I group couples into a number of religious categ…
Negative values for categorical variable.Hello, I have been using R but started learning STATA recently. To briefly introduce what I have be…
Subscribe to:
Post Comments (Atom)
0 Response to Collapse command error message that has me stumped
Post a Comment