I have a small long format dataset below.
* Example generated by -dataex-. For more info, type help dataex
clear
input byte (gender period pr)
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
I want to create a new variable sum_pr,
which equals to the sum of the first value within gender and period like below:
* Example generated by -dataex-. For more info, type help dataex
clear
input byte (gender period pr sum_pr)
1 1 11 26
1 1 11 26
1 1 11 26
1 2 15 26
1 2 15 26
1 2 15 26
2 1 11 23
2 1 11 23
2 1 11 23
2 2 12 23
2 2 12 23
2 2 12 23
end
How can I use Stata code to achieve it?
Thank you!
Related Posts with How to compute the sum of the first occurence within Group(s) in Stata?
Error terms for Time Series Regression with a Panel VariableDear all, For my master thesis, I would like as a first step to run a Fama-French three factor regr…
Mean of a group minus the observation's value in Panel dataHi, I have a data structure like this: IO-IOarea-Year-index 1----4-------1997-0 2----4-------1998-…
How to regress categorical variables without baseHello, Currently I am investigating the impact of industry categorization (categorical variable) on…
Command problem with counting sample firms smaller than the firm for each country in each year (panel data)Hi, guys, I would like to measure the percentage of sample firms smaller than the firm for each coun…
How to change display of scientific notation of summary statistics to nummeric?Stata 15.1 I am attempting to create a descriptive statistics table for my thesis. However, I found…
Subscribe to:
Post Comments (Atom)
0 Response to How to compute the sum of the first occurence within Group(s) in Stata?
Post a Comment