Dear all,
I'm struggling to do the following:
I have the following continuous variables:
Month1Volume1
Month1Volume2
Month1Volume3
Month2Volume1
Month2Volume2
...
Month74Volume3
and I'm trying to do 2 things, change all missing data to zero and create a variable that represents the sum of all 5 volumes in a month. For that I tried the below code without success:
forval i=1/74{
forval j=1/5{
replace Month`i'Volume`j'=0 if Month`i'Volume`j'=.
}
{
forval i=1/74{
generate Volume`i'=.
forval j=1{
replace Volume`i'=(Month`i'Volume`j') + (Month`i'Volume`=`j'+1')+ (Month`i'Volume`=`j'+1')
}
}
Stata return invalid syntax for both attempts
Could anyone help? I was recently introduced to forval and obviously missing something
Sincerely
Thyago
I'm struggling to do the following:
I have the following continuous variables:
Month1Volume1
Month1Volume2
Month1Volume3
Month2Volume1
Month2Volume2
...
Month74Volume3
and I'm trying to do 2 things, change all missing data to zero and create a variable that represents the sum of all 5 volumes in a month. For that I tried the below code without success:
forval i=1/74{
forval j=1/5{
replace Month`i'Volume`j'=0 if Month`i'Volume`j'=.
}
{
forval i=1/74{
generate Volume`i'=.
forval j=1{
replace Volume`i'=(Month`i'Volume`j') + (Month`i'Volume`=`j'+1')+ (Month`i'Volume`=`j'+1')
}
}
Stata return invalid syntax for both attempts
Could anyone help? I was recently introduced to forval and obviously missing something
Sincerely
Thyago
Comment