Announcement

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

  • Catplot by two groups

    Hello,

    I am trying to use catplot to graph a categorical variable for two groups. I would like to have a blue bar and a red bar side by side. My data are below. I want to graph rmvl_rtrn_rsn1 by inc_parent (which equals 1 or 0). Have a blue bar if it equals 0 and a red bar if it equals 1 and have them side by side. I tried using over and by, but this just separates them into two different graphs and I would like them side by side as they have the same reasons. TIA for any help- CJ

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str63 rmvl_rtrn_rsn1 float inc_parent
    "Return Home"                                                     0
    "Return Home"                                                     1
    "Return Home"                                                     1
    "Return Home"                                                     0
    "Return Home"                                                     1
    "Return Home"                                                     1
    "Return Home"                                                     0
    "Return Home"                                                     0
    "No Data"                                                         1
    "Return Home"                                                     0
    "Youth is 18+ and No Affidavit/Conciliation"                      0
    "Return Home"                                                     1
    "Return Home"                                                     0
    "Return Home"                                                     0
    "Return Home"                                                     0
    "Return Home"                                                     0
    "No Data"                                                         1
    "Return Home"                                                     0
    "Youth is 18+ and No Affidavit/Conciliation"                      0
    "Permanent Legal Custodianship"                                   1
    "Return Home"                                                     1
    "Return Home"                                                     0
    "Return Home"                                                     0
    "Return Home"                                                     1
    "Return Home"                                                     0
    "No Data"                                                         0
    "Return Home"                                                     0
    "Return Home"                                                     1
    "Return Home"                                                     0
    "Return Home"                                                     0
    "No Data"                                                         0
    "No Data"                                                         0
    "No Data"                                                         0
    "No Data"                                                         1
    "Permanent Legal Custodianship"                                   1
    "Return Home"                                                     0
    "Return Home"                                                     1
    "Return Home"                                                     0
    "Return Home"                                                     0
    "Return Home"                                                     0
    "Return Home"                                                     0
    "Youth is 18+ and No Affidavit/Conciliation"                      1
    "Return Home"                                                     1
    "Return Home"                                                     0
    "Return Home"                                                     0
    "Return Home"                                                     1
    "Return Home"                                                     1
    "Return Home"                                                     1
    "Return Home"                                                     0
    "Return Home"                                                     0
    "Return Home"                                                     0
    "Return Home"                                                     0
    "Youth is 18+ and No Affidavit/Conciliation"                      0
    "Youth is 18+ and No Affidavit/Conciliation"                      0
    "Youth is 18+ and No Affidavit/Conciliation"                      1
    "Return Home"                                                     0
    "No Data"                                                         0
    "No Data"                                                         0
    "No Data"                                                         0
    "Return Home"                                                     0
    "Return Home"                                                     0
    "Return Home"                                                     1
    "Return Home"                                                     1
    "Return Home"                                                     0
    "Return Home"                                                     0
    "Adoption"                                                        1
    "No Data"                                                         0
    "Return Home"                                                     0
    "No Data"                                                         0
    "Return Home"                                                     1
    "Return Home"                                                     1
    "Adoption"                                                        0
    "No Data"                                                         1
    "Return Home"                                                     0
    "Return Home"                                                     0
    "No Data"                                                         0
    "No Data"                                                         0
    "Return Home"                                                     0
    "Youth is 18+ and No Affidavit/Conciliation"                      0
    "Permanent Legal Custodianship"                                   1
    "Return Home"                                                     0
    "Return Home"                                                     0
    "Return Home"                                                     0
    "Return Home"                                                     1
    "Return Home"                                                     1
    "Return Home"                                                     1
    "Return Home"                                                     0
    "Return Home"                                                     0
    "Return Home"                                                     1
    "Return Home"                                                     0
    "Return Home"                                                     0
    "No Data"                                                         0
    "Return Home"                                                     0
    "Return Home"                                                     0
    "Permanent Placement in the Home of a 'Fit and Willing' Relative" 1
    "No Data"                                                         0
    "Return Home"                                                     1
    "Return Home"                                                     1
    "Return Home"                                                     0
    "Return Home"                                                     1
    end

  • #2
    Nevermnd I figured this out! Thanks!

    Comment


    • #3
      Closure like #2 is better than just walking away but it misses the major point of Statalist, which is not to be a helpline to individuals in public, but to be a public forum in which questions and answers may be of interest to many.

      We can have no idea what your solution was, but here's mine.


      catplot
      is from SSC, as you are asked to explain (FAQ Advice #12).

      We have to guess at what code you tried, as you don't give any.

      catplot allows over() and by() options, but the main point is let the order of variables in the varlist indicate the desired layout.

      In this case it seems that

      Code:
      catplot inc_parent rmvl, asyvars bar(2, color(red)) bar(1, color(blue))
      satisfies your criteria, but the string variable needs to be trimmed down to get a nicer display.

      Comment

      Working...
      X