Hello,
I am facing an issue with the collapse command. I am collapsing my dataset of individual observations by year and a subcategory (rural/urban) to find the mean of the variable of interest. My command is :
(Urban is a dummy variable that takes the value 1 if the individual observation is from an urban locality and 0 otherwise)
However, I also need to find the mean of the variable of interest only by year to show how the variable of interest changes over time, when in the entire population, and among subcategories of the population (urban or rural in this case).
However, once, I have collapsed my dataset by year and subcategory, there is no way I can calculate how the variable of interest changes over time, in the entire population -other than reloading the dataset, running the collapse command by year and then merging the 2 results- one where I collapse the dataset by year and urban/rural, and one where I collapse the dataset only by year.
Is there a way I can do this, without going about this route?
I would appreciate any help on this!
Thank you,
Kanika
I am facing an issue with the collapse command. I am collapsing my dataset of individual observations by year and a subcategory (rural/urban) to find the mean of the variable of interest. My command is :
Code:
collapse(mean) variable_of_interest, by(year urban)
However, I also need to find the mean of the variable of interest only by year to show how the variable of interest changes over time, when in the entire population, and among subcategories of the population (urban or rural in this case).
However, once, I have collapsed my dataset by year and subcategory, there is no way I can calculate how the variable of interest changes over time, in the entire population -other than reloading the dataset, running the collapse command by year and then merging the 2 results- one where I collapse the dataset by year and urban/rural, and one where I collapse the dataset only by year.
Is there a way I can do this, without going about this route?
I would appreciate any help on this!
Thank you,
Kanika
Comment