How do I get a group minimum over level combinations of factors?
I would like to find minimum values within groups. In stata, I think it is simply "by group,开发者_高级运维 sort : egen minvalue=min(value)"... I tried to mess around with ave and rowsum, but to no avail. ave(value, group, FUN=min) did not work.
Sorry this answer is a little late but, in case you are still looking for the answer or for future searchers here goes....
You are onto the right track with the -by- command. Here is what I'd do to find the lowest price of cars in the auto.dta dataset by domestic/foreign grouping.
sysuse auto, clear
bysort foreign : egen minprice = min(price)
What this does is create a new variable 'minprice' that holds the minimum price for domestic cars if a given car (observation) is domestic and vice versa for foreign cars. So this new variable with have just two values in this example and you can check that by doing:
tabulate minprice
Depending on why you wanted to find the minimum values by group this may not be what you had in mind but hopefully someone finds it helpful.
 加载中,请稍侯......
      
精彩评论