Hello,
I want to write a code that creates a value which is the summation of several rows. I have negative values in my data and I want to ignore those values in the summation. I have run the following code but it is giving me missing values.
local x owe1 owe2 owe3 owe4
foreach x in `x'{
gen loan_1998= owe1+ owe2+ owe3+ owe4 if `x'>0
}
Here is how my data is looking like: it is a survey data and the the value -4 corresponds to a valid skipped.
I am wondering if someone can please help me figure out what is wrong?
Thank you for your assistance!
I want to write a code that creates a value which is the summation of several rows. I have negative values in my data and I want to ignore those values in the summation. I have run the following code but it is giving me missing values.
local x owe1 owe2 owe3 owe4
foreach x in `x'{
gen loan_1998= owe1+ owe2+ owe3+ owe4 if `x'>0
}
Here is how my data is looking like: it is a survey data and the the value -4 corresponds to a valid skipped.
PUBID | SEX | BDATE_M | BDATE_Y | CV_SAMPLE_TYPE | RACE_ETHNICITY | owe1 | owe2 | owe3 | owe4 | owe_1998 |
96 | Male | 2982616 | 1982 | Cross-sectional | Non-Black / Non-Hispanic | -4 | -4 | -4 | -4 | . |
97 | Male | 2982616 | 1980 | Cross-sectional | Hispanic | -4 | -4 | -4 | -4 | . |
98 | Male | 2982616 | 1980 | Cross-sectional | Non-Black / Non-Hispanic | -4 | -4 | -4 | -4 | . |
99 | Male | 2982616 | 1982 | Cross-sectional | Hispanic | -4 | -4 | -4 | -4 | . |
100 | Female | 2982616 | 1981 | Cross-sectional | Black | -4 | -4 | -4 | -4 | . |
101 | Female | 2982616 | 1981 | Cross-sectional | Black | -4 | -4 | -4 | -4 | . |
102 | Female | 2982616 | 1982 | Cross-sectional | Hispanic | -4 | -4 | -4 | -4 | . |
103 | Female | 2982617 | 1983 | Cross-sectional | Hispanic | -4 | -4 | -4 | -4 | |
104 | Female | 2982617 | 1980 | Cross-sectional | Non-Black / Non-Hispanic | -4 | 1500 | -4 | -4 | . |
105 | Male | 2982617 | 1983 | Cross-sectional | Non-Black / Non-Hispanic | -4 | -4 | -4 | -4 | . |
106 | Male | 2982617 | 1981 | Cross-sectional | Non-Black / Non-Hispanic | -4 | -4 | -4 | -4 | . |
107 | Female | 2982617 | 1982 | Cross-sectional | Non-Black / Non-Hispanic | -4 | -4 | -4 | -4 | . |
108 | Male | 2982617 | 1984 | Cross-sectional | Non-Black / Non-Hispanic | -4 | -4 | -4 | -4 | . |
109 | Female | 2982616 | 1982 | Cross-sectional | Non-Black / Non-Hispanic | -4 | -4 | -4 | -4 | . |
110 | Female | 2982616 | 1984 | Cross-sectional | Non-Black / Non-Hispanic | -4 | -4 | -4 | -4 | . |
111 | Female | 2982616 | 1981 | Cross-sectional | Non-Black / Non-Hispanic | -4 | -4 | -4 | -4 | . |
112 | Female | 2982616 | 1984 | Cross-sectional | Non-Black / Non-Hispanic | -4 | -4 | -4 | -4 | . |
113 | Male | 2982616 | 1984 | Cross-sectional | Non-Black / Non-Hispanic | -4 | -4 | -4 | -4 | . |
114 | Female | 2982616 | 1982 | Cross-sectional | Non-Black / Non-Hispanic | -4 | -4 | -4 | -4 | . |
115 | Female | 2982617 | 1984 | Cross-sectional | Hispanic | -4 | -4 | -4 | -4 | . |
116 | Male | 2982617 | 1984 | Cross-sectional | Black | -4 | -4 | -4 | -4 | . |
Thank you for your assistance!