Dear Stata Forum,
I have a panel data with several groups. Year and ID with three variables : variable_1 (dummy), variable_2 (continuous) and variable_3(dummy).
I have been using the following egen command to compute aggregates without missing values:
bys year: egen var_sum = sum(cond( variable_1 == 1, variable_2, .))
My question is whether it is possible to include more conditions in the above syntax as I want to compute aggregates in the intersection of vairable_1 and variable_3.
Thank you.
Best wishes,
Manish
Related Posts with egen with conditions
Loop variable values as labels in a forval line graphHi, I am trying to plot GDP for a set of countries and generate a legend which identifies each line…
Issue with Reshape Code: * Example generated by -dataex-. To install: ssc install dataex clear input str25 VarYr str2…
PISA data and using country fixed effectsHello, I am working with PISA 2012 dataset and I am comparing Eastern and Western European countrie…
Working with bootstrap, program and foreachHello, I have investigated my problem and have not been able to find a solution. I would like to ca…
Get no. of times for loop has iteratedIs there a way that I can access the number of times a given loop is on. For example, Code: sysus…
Subscribe to:
Post Comments (Atom)
0 Response to egen with conditions
Post a Comment