I tried a few egen commands to do what I need, but can't figure it out.
I want to create a new variable that returns a total by each unique value in the the "country" column.
EX:
have:
want:
I want to create a new variable that returns a total by each unique value in the the "country" column.
EX:
have:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str5 country float "USA" "USA" "USA" "China" "China" "USA" "USA" "USA" "China" "China" end
country | countryfreq |
USA | 6 |
USA | 6 |
USA | 6 |
USA | 6 |
China | 4 |
China | 4 |
China | 4 |
China | 4 |
USA | 6 |
China | 4 |
Comment