I have a data on average sales of corporation for the past 6 months. Below you can see a part of the table. I want to create a new column that counts how often each corporation or each id has made more than $ 50,000.
id | sal_20120101 | sal_20120601 | sal_20121201 | sal_20130101 | sal_20130601 | sal_20131201 | sal_20140101 | sal_20140601 | sal_20141201 | sal_20150101 |
1 | 20,640 | 20,640 | 20,640 | 20,800 | 20,800 | 20,800 | 20,800 | 20,800 | 20,800 | 20,800 |
2 | 87,320 | 87,320 | 92,000 | 92,000 | 92,000 | 92,000 | 95,330 | 95,330 | 95,330 | 95,330 |
3 | 47,890 | 47,890 | 49,530 | 49,530 | 49,530 | 62,110 | 62,110 | 62,110 | 63,000 | 63,000 |
4 | 122,810 | 122,810 | 115,200 | 115,200 | 0 | 0 | 0 | 0 | 0 | 0 |
bysort id: gen count = count if sal_* > 50000
I also tried anycount and loops like foreach but I dont get the result.
I hope you can help.
0 Response to count if variables meet conditions
Post a Comment