Hey everyone,
I have a very easy question, but I am just not solving it. Let's suppose I have two departement with a given variable x. My dataset looks like:
Departement x
1 5
1 7
1 7
2 2
2 2
2 2
Now, I want to create a variable which sums all DISTINCT values of x by departement. So my dataset should look like:
Departement x y
1 5 12
1 7 12
1 7 12
2 2 2
2 2 2
2 2 2
How do I do that?
Best,
Simeon
Related Posts with Sum distanct values of a variable by group
post hoc for Fisher's exact testHello. Hope everyone is doing well. I would like to do a post hoc test after Fisher's exact test. I…
Loop to merge multiple dta filesHi all, I am trying to run a loop to merge 10 files names year_1, year_2, ...., year_10 all at once…
Sensitivity testHello fellow stata users! I am in the midst of writing my bachelor thesis and I'm doing a cross-sec…
Assign value to a categorical variable between two limitsDear users, hope everyone is well. i want to assign value of 3 to the variable "dum" when the curre…
Counting Observations in Panel Data and filling in missing valuesHello everyone, I am new to STATA and have a question regarding the preparation of my Data sample. "…
Subscribe to:
Post Comments (Atom)
0 Response to Sum distanct values of a variable by group
Post a Comment