copy and paste this google map to your website or blog!
Press copy button and paste into your blog or website.
(Please switch to 'HTML' mode when posting into your blog. Examples: WordPress Example, Blogger Example)
How can I rank observations within groups in Stata? This isn't ranking in most senses that I have seen discussed, but Stata's egen, rank() does get you part of the way But the direct way, which was mentioned in the Statalist thread cited elewhere in this thread (start here) is simpler in spirit than any solution quoted:
Stata: tag all values in a group based on a characteristic of any . . . 2 I think egen might help me here, but for whatever reason I can't quite figure out the right syntax I'd like to create a new variable that takes a value of 1 for all observations in a group if, for any of the observations in the group, X is true
Getting the sum of two variables on Stata with missing values How do I generate a new variable which gives me the sum of two variables (msf_n_4weeks and msm_n_4weeks) but only assigns a missing value if BOTH of the values for the variables is missing The var
Row-wise count sum of values in Stata - Stack Overflow I had the same problem to count the occurrences of specific values in each observation across a set of variables I could resolve that problem in the following way: If you want to count the occurrences of 0 in the values across x1-x3, then clear input id x1 x2 x3 1 1 0 2 2 2 0 2 3 2 0 3 end egen count2 = anycount(x1-x3), value(0)
How to compute the sum of some variables in Stata? Here is a solution for how to do it in two steps: * Example generated by -dataex- For more info, type help dataex clear input str2 ID byte(var1 var2 var3 var4) "xx" 0 0 1 1 "yy" 1 0 0 9 "zz" 3 2 1 0 end egen row_sum = rowtotal(var*) Sum each row into a var egen tot_var = sum(row_sum ) Sum the row_sum var * Get the value of the first observation and store in a local macro local total = tot