I am trying to find outliers in a variable called nbrs
, generating an interquartile (iqr) range called nbrs_iqr
. I then want to loop (for practice with this looping concept) the values 1.5, 2, 5, and 10 in to multiply them by the iqr.
I keep getting a syntax error (invalid syntax r(198);) on the loop. I have seen something about not being able to do the forvalues loop when the values are not a range but have seen examples where it is a non-range without being explicit that that is permitted. I figured the spaces worked to separate the non-range values but I've thrown up my hands from there.
sum nbrs, detail
return list
gen nbrs_iqr = r(p75)-r(p25)
tab nbrs_iqr
forvalues i = 1.5 2 5 10 {
gen nbrs_out_`i'=`i'*nbrs_iqr
}