Hello, I am trying to generate a new variable equal to the sum for a number of observations only if none of the observations are missing (see data below) and equal to missing if any observation is missing. I cannot use a simple STATA command such as sum or total as these take missings as zero. Any help on this is very much appreciated.
I need to do this after using mi impute, so should hopefully something that can be use with mi passive.
Thank you very much in advance.
Rodolfo.
I need to do this after using mi impute, so should hopefully something that can be use with mi passive.
Thank you very much in advance.
Rodolfo.
StudyNo | Var1 | NewVariable |
1 | 0 | . |
1 | 1 | . |
1 | 1 | . |
1 | 2 | . |
1 | 1 | . |
1 | . | . |
2 | 0 | . |
2 | 2 | . |
2 | 2 | . |
2 | . | . |
3 | 0 | 16 |
3 | 1 | 16 |
3 | 2 | 16 |
3 | 1 | 16 |
3 | 3 | 16 |
3 | 4 | 16 |
3 | 5 | 16 |
4 | 0 | . |
4 | 0.07 | . |
4 | 0.01 | . |
4 | 0.01 | . |
4 | 0.03 | . |
4 | 0.02 | . |
4 | 0.05 | . |
4 | . | . |
Comment