I have datasets which has a categorical variable(e.g : Crops) and few continuous variables (e.g: price, yield, area ). I want to write a loop which will summarize price by each category of crops. I tried using "levelsof" cmd but i get the same result for all the variables. I used the command below. Any advice on this would be helpful.
levelsof crop,local (crop)
foreach i in `crop'{
asdoc sum price, ///
stat(N mean median min max iqr p25 p75 ) ///
label append save(DistributionsMainOutcomes_`today'.doc) ///
title( Price)
asdoc sum yield , ///
stat(N mean median min max iqr p25 p75 ) ///
label append save(DistributionsMainOutcomes_`today'.doc) ///
title( Yield)
}
levelsof crop,local (crop)
foreach i in `crop'{
asdoc sum price, ///
stat(N mean median min max iqr p25 p75 ) ///
label append save(DistributionsMainOutcomes_`today'.doc) ///
title( Price)
asdoc sum yield , ///
stat(N mean median min max iqr p25 p75 ) ///
label append save(DistributionsMainOutcomes_`today'.doc) ///
title( Yield)
}
Comment