The long format dataset is presented as follows.
It has 3 columns,
gender (male=1; female=2),
period (1=elementary school;2=middle school;3=high school);
pat=average physical activtiy time per day.
Now, I want to use Stata code to create a new column daily_pat,
which should be equal to the running sum of pat by gender and period.
Thank you for your help!
* Example generated by -dataex-.
clear
input byte (gender period pat)
1 1 11
1 1 11
1 1 11
1 2 15
1 2 15
1 2 15
2 1 11
2 1 11
2 1 11
2 2 12
2 2 12
2 2 12
end
Related Posts with Ask for Help with Computation of Running Sum of a Variable within Multiple Variables in Stata.
"randomselect" in a program used in a simulationHello! I am working on a program that aims to make randomization inference of four coefficients fro…
Looping through multiple dependent variables with outreg2Dear all, I would like to run several regressions, looping through different dependent variables an…
Interpreting coefficients in logitDear Statalist, I'm running a logit model and one of my coefficients is -1.0954 and statistically s…
looping over observations - retaining the values from previous observationsHello all I am trying to find out the length of wait for each individual for a service given we know…
When does multi-collinearity increase significance of regressors?I'm stuck with some unexpected findings that seem to contradict what I (thought I) knew about multic…
Subscribe to:
Post Comments (Atom)
0 Response to Ask for Help with Computation of Running Sum of a Variable within Multiple Variables in Stata.
Post a Comment