Hello,
I previously posted a thread about stacking variables. See here: https://www.statalist.org/forums/for...ange-of-values
I cannot post the data, so I use the example of people being surveyed on their two favorite foods. The data looks like this:
The fav1 and fav2 variables would be stacked into one variable this way:
A bar graph of this would be created:
In addition to a normal bar graph, I would like to do separate bar graphs by gender. Is there a way to preserve the gender variable through the stack, in order to later create two separate bar graphs by gender?
I previously posted a thread about stacking variables. See here: https://www.statalist.org/forums/for...ange-of-values
I cannot post the data, so I use the example of people being surveyed on their two favorite foods. The data looks like this:
Code:
ID fav1 fav2 gender 1 pizza burger 0 2 burger pizza 1 3 steak burger 1 4 burger steak 0
Code:
stack fav1 fav2, into(fav)
Code:
graph bar (count), over(fav)
Comment