Announcement

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

  • Help creating a bar graph over multiple variables

    Greetings,
    When creating a graph bar and dividing it over a variable, I cant figure out a way to add in the same graph a bar for the whole dataset. Something like this:
    Click image for larger version

Name:	Helpneeded.JPG
Views:	1
Size:	68.8 KB
ID:	1703377



    I have tried creating a variable "whole" and use the over two times when generating the graph but that doesnt seem to work.

    Code:
    gen whole = 1
    graph bar una_tic todas_tic, over(area_estudio) over(whole)
    Here, una_tic and todas_tic are the variables im interested on taking the mean of. area_estudio is the variable that divides my dataset

    Any help is appreciated

    Mateo Podesta
    Last edited by Mateo Podesta; 24 Feb 2023, 17:46.

  • #2
    Maybe expand the dataset to create a "whole" category for area_estudio:
    Code:
    expand 2, gen(whole)
    replace area_estudio="Total" if whole==1 // assuming it is currently coded as string
    graph bar una_tic todas_tic, over(area_estudio)

    Comment


    • #3
      Thanks, Daniel. It worked!

      Comment

      Working...
      X