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
Avoiding merge m:m problem...Dear Statalisters: I have the following file #1: clear input byte(firmid ownerid) float own byte l…
Reshaping from "strange" to long formatDear StataListers, I use Stata 14.2. Here is a simplified example of my data (three cities, three y…
How to move State ApplicationI have Stata 13 MP on my current laptop (Macbook Air)). I have just bought a new laptop (MacBook Air…
Panel data with messy time, very large NDear users, My data consists of N=1033 and T=1-15, with a total number of observation of 2300. Time…
How to set width Stata MP 16.1 for UnixHello, I am using Stata 16.1 (64-bit, total usable memory 1510.3 GB), and trying to change an extre…
Subscribe to:
Post Comments (Atom)
0 Response to Generating variables and compute average with if conditions
Post a Comment