Announcement

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

  • Create distribution of panel data for each year and industry

    Hi!

    I like to create a scatter plot where I can show simultaneously for 10 industries the average firm_size for each year by having multiple courses (sperated by different coulours) in one chart.
    Is that possible in stata? Until now I was only able to create a distribution dependent by one variable :

    Code:
    bysort year: egen av_firm_size = mean(firm_size)
    I thought about an if-operator but if I repeat this command it obviously says that I gernate the variable before:

    Code:
    bysort year: egen av_firm_size = mean(firm_size) if SIC_1==1
    Do you have any advice for me that is replicable displaybale in the graph afterwards?
    Many thanks!

  • #2
    10 may be too many to go back and forth from the graph to the legend. Here is some technique:

    Code:
    webuse grunfeld, clear
    keep if company<5
    gen yr= real(ustrregexra(string(year), "19(\d+)", "$1"))
    collapse mvalue, by(company yr)
    separate mvalue, by(company) veryshortlabel
    set scheme s1color
    tw dot mvalue? yr, vert xtitle("") xlab(35/54) msy(Oh + Th Sh)
    Res.:

    Click image for larger version

Name:	Graph.png
Views:	1
Size:	51.7 KB
ID:	1668204

    Comment

    Working...
    X