'How can I combine bysort with tabulate and export all of the tables into Excel?
I have a dataset that has rankings for cars (New, not new, medium, old) as a string variable. Another variable is also a string variable that functions as a dummy (car has 4 wheels is “yes”, while car doesn’t have 4 wheels is “no”). How do I find the share of cars that have four wheels, but for each of the rankings of cars? For the first table will give me the proportion of cars with 4 wheels out of all “new” cars, as well as the proportion of cars without 4 wheels out of all “new cars”. This repeats for each ranking of car.
I tried bysort Car_rankings: eststo tabulate four_wheels but it doesn’t work. What should I do?
| Car_rankings | four_wheels | id |
|---|---|---|
| New | yes | AJ4123 |
| not new | yes | AK124 |
| medium | no | KL41241 |
| old | yes | ANV41223 |
This is just an example dataset and my actual one has many more rows.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
