Hello everyone,
I need to count the number of times a condition was satisfied. I have got different variables which are gdp quarterly levels, Q12008-Q42015.
I want to know how many quatrimesters the gdp was below the initial level (varname maxval_crisis).
I am using the following command:
gen count = 0
gen sum = 0
forval j = Q12008/Q42015 {
replace count = count + ( var `j' < maxval_crisis )
replace sum = sum + var `j' if var `j' < maxval_crisis
}
data are attached. Thanks for your help.
Best,
I need to count the number of times a condition was satisfied. I have got different variables which are gdp quarterly levels, Q12008-Q42015.
I want to know how many quatrimesters the gdp was below the initial level (varname maxval_crisis).
I am using the following command:
gen count = 0
gen sum = 0
forval j = Q12008/Q42015 {
replace count = count + ( var `j' < maxval_crisis )
replace sum = sum + var `j' if var `j' < maxval_crisis
}
data are attached. Thanks for your help.
Best,
Comment