I'm trying to create a dummy variable that takes on a value of 1 if another (continuous) variable (=PSLIQ) is higher than 2 times its corresponding standard deviation and takes on a value of 0 otherwise.
The variable that I am looking at is "PSLIQ" in my dataset and it has a standard deviation of around 0.033.
I've already tried doing:
egen stdev = sd(PSLIQ)
but that is where I get stuck. Hopefully someone can help, thanks!
Here is an example of my dataset:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float mdate double PSLIQ 141 .03750459 142 .00751077 143 .00199699 144 -.03374327 145 .00993984 146 .03309115 147 .01508518 148 -.00148126 149 .01372639 150 .01622972 151 -.03104982 152 -.01488973 153 -.01545361 154 -.00776205 155 .00882111 156 -.01481098 157 -.01086541 158 -.01271889 159 .02308621 160 -.00263267 161 -.03231649 162 .0024503 163 .01594605 164 .01702629 165 -.04308556 166 -.0265017 167 -.01684214 168 .10501732 169 .03898203 170 .04593273 171 .02365498 172 .06008724 173 -.01077655 174 -.00473158 175 -.0286962 176 .02436165 177 -.07885913 178 -.01939789 179 .02044962 180 .10883999 181 .03674259 182 .05999037 183 .00210471 184 -.03234878 185 -.01805181 186 -.00983661 187 -.00842826 188 -.01923828 189 .09125723 190 .03609542 191 -.00323456 end format %tm mdate
0 Response to Creating a dummy based on a condition
Post a Comment