Dear all,
I’m new to stata and for my research I need the following:
I have two treatments:
1) Focus (0/1/2) where 0 stands for control and 1 for process and 2 for Outcome.
2) Certainty (0/1/) where 0 stands for certain and 1 for uncertain.
I want to generate variables for all the possible combinations CC=(0/0) CO= (0/1) CP=(0/2) & UC=(1/0) UO=(1/1) UP(1/2).
If I gen CC and replace CC = 1 if Certainty==0 & Focus==0, I get 0 real changes. What other code can I use to fix this?
Moreover, I have the variable BP and BP2.
I want to generate avgBP1 for all variables above: egen avgBP1 = mean(CC) such that I can compare the average of BP1 between all combinations.
Due to the 0 changes in the first code this gives me means of 0.
Should I instead of generating variables, make use of more if functions?
E,g. egen avgBP1 = rmean(BP1) if Certainty==0 & Focus==0
This gives me 97 (n=97) missing values.., but I don’t know how to continue.
Thanks in advance!
Daniël
Related Posts with Generating variables and compute average with if conditions
table / collect - odd behaviourI am trying to construct a simple table following a paired -test to show the mean difference, p valu…
Matching: Conditioning on lagged dependent variablesHi everybody, I wondered whether it does make sense to condition on the lagged dependent variable w…
Quantify the effect size of an interaction termHello, I have a doubt that it is not specific about Stata. However, I would like to ask you for an…
Grouped Difference of Mean TestDear all, I want to perform a difference of means test on my dataset, to see whether there is a dif…
Power Analysis [power] in Context of Regression Analysis and Robust Standard ErrorsHi, Based on the results of a regression analysis, I would like to perform a power analysis that ac…
Subscribe to:
Post Comments (Atom)
0 Response to Generating variables and compute average with if conditions
Post a Comment