Dear Statalist Forum,
I am encountering a somewhat confusing issue. Here is a simplified context of the dataset:
-Several variables for different crops (_mean_crop1, _mean_crop2, _mean_crop3, etc)
-By year and district in the US (year district)
Objective of code:
-calculate mean of all crops by year and district
Speculated code:
However, I am getting the following error:
'_mean_crop1_mean_crop2_mean_crop3 not found r(111)'
For multiple variables, I thought we could just list var1 var2 var3 in -egen- commands but here they are being force together? I have tried renaming them to not lead with '_' but the behavior persists.
Would a suitable solution be:
I thought this might alter the mean() value that is being calculated...
I am encountering a somewhat confusing issue. Here is a simplified context of the dataset:
-Several variables for different crops (_mean_crop1, _mean_crop2, _mean_crop3, etc)
-By year and district in the US (year district)
Objective of code:
-calculate mean of all crops by year and district
Speculated code:
Code:
egen agg_crop_mean = mean(_mean_crop1 _mean_crop2 _mean_crop3), by(district year)
'_mean_crop1_mean_crop2_mean_crop3 not found r(111)'
For multiple variables, I thought we could just list var1 var2 var3 in -egen- commands but here they are being force together? I have tried renaming them to not lead with '_' but the behavior persists.
Would a suitable solution be:
Code:
egen agg_crop_mean = mean(_mean_crop1 + _mean_crop2 + _mean_crop3), by(district year)
Comment