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
Panel DataHey everyone, I'm fairly new to using Stata, so im still getting use to everything. I am using unbal…
Do the regression for only one company each and saving them to an excel/doc (ASDOC)Hi everybody, I do have a panel dataset where every company has a unique ID (-company-) and their r…
CONSORT DiagramDear Statalist, Is is possible to create a CONSORT flow diagram in stata without specifying the coo…
Mean of a variable by multiple variables in the same tableHi. In my data there are 20 variables (var1- var20) which are deciles created based on different fa…
merging multiple excel file from a folder using key variable household id and monthI have many excel files in a folder and each data file contains variable VDS_ID and SUR_MON_YR. I wa…
Subscribe to:
Post Comments (Atom)
0 Response to Generating variables and compute average with if conditions
Post a Comment