Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bar graph of two string variables with same range of values

    Hello,

    I am attempting to make a bar graph of two string variables that can take on the same value. The two variables are answers to survey questions. I can't post the data, but we can pretend the people were asked their two favorite foods. The data would look like this:

    Code:
    ID fav1 fav2
    1 pizza burger
    2 burger pizza
    3 steak burger
    4 burger steak
    I would simply like to count the frequencies of all of the answers to fav1 and fav2. I've looked into the stack command, but I don't want to distinguish between fav1 and fav2 in the bar graph, which I don't think is possible using stack.

  • #2
    Code:
    clear 
    input ID str6(fav1 fav2) 
    1 pizza burger
    2 burger pizza
    3 steak burger
    4 burger steak
    end 
    
    stack fav1 fav2, into(fav) 
    graph bar (count), over(fav)

    Comment


    • #3
      That solved my problem. Thank you.

      Comment

      Working...
      X