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.
What are some Stata skills that you need to do RA for professors? And what are the good sources to learn data cleaning?I'm about to work as a RA for a professor, what would I be expected to do? I have heard that data cl…
Merging multiple panel data filesHello all, I have individual panel data and two state-level panels I seek to merge together. I have…
Binary Endogenous variable in Negative binomial regressionHello everybody, In my research, the dependent variable (DV) is count data and endogenous variable …
Gravity estimation including fixed effectsHi everyone, I am estimating a gravity model of trade including exporter-time and importer-time fix…
What does "log using 'filename', replace" do? To create logs or to replace the existing ones?Dumb question, but in my professor's notes it's to "create log in current folder." But isn't it foll…
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