Announcement

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

  • test, please ignore

    Hi all,
    I am trying to emulate a graph that's coupled with a table in Stata that I've done for years in SAS. I've converted almost all my other code over to Stata but have not been able to figure out how to create a Stata graph that reproduces what I get from Proc Gchart in SAS which has descriptive stats lined up with the bars of a chart. To demonstrate I've redone my code with Stata's famous auto.dta file:

    The SAS code and what it produces is

    PROC GCHART data=auto;
    HBAR mpg / TYPE=PCT MIDPOINTS= 44 TO 12 BY -4
    maxis=axis1;
    title font='Times' height=.15 in
    'Distribution of mpg';
    title2 'Test for comparison with Stata';
    run;





    Now, I can get close. For example, to create a bar chart that - once I fool with the formatting which is clearly off in the following - would duplicate Gchart:

    hist mpg , percent ylabel( , angle(horizontal) ) horizontal bin(8) start(10) barwidth(2.95)





    And I can, inelegantly, get the matching descriptive stats:

    . egen cmpg1 = cut(mpg), at(9.999(4)42)
    . tabulate cmpg1


    cmpg1 | Freq. Percent Cum.
    ------------+-----------------------------------
    9.999 | 2 2.70 2.70
    13.999 | 16 21.62 24.32
    17.999 | 25 33.78 58.11
    21.999 | 17 22.97 81.08
    25.999 | 7 9.46 90.54
    29.999 | 3 4.05 94.59
    33.999 | 3 4.05 98.65
    37.999 | 1 1.35 100.00
    ------------+-----------------------------------
    Total | 74 100.00




    But I'd like to output, like Gchart, the bar chart with the aligned descriptives so that aligned with each bar is that bar's frequency, cumulative freq, percent freq, and cumulative freq. I have to do this about 40 times looping over various subsets of data and so would like something automated. Any help would be appreciated!

    Thanks.

    Kurt
Working...
X