Announcement

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

  • "Command ysca is unrecognized" - from help graph_combine

    Hi,

    I am currently looking at the graph_combine help file to solve the problem that I have posted here with no success (if anyone has the solution, it would be greatly appreciated, I have been looking for a solution for hours now...)
    https://www.statalist.org/forums/for...with-no-margin

    I am trying to run the code as listed in the help file under "Advanced use" but I'm getting an "Command ysca is unrecognized" error. Do I need to ssc install something prior running this code?

    Code:
            . sysuse lifeexp, clear
    
            . gen loggnp = log10(gnppc)
    
            . label var loggnp "Log base 10 of GNP per capita"
    
            . scatter lexp loggnp,
                    ysca(alt) xsca(alt)
                    xlabel(, grid gmax)      saving(yx)
    
            . twoway histogram lexp, fraction
                    xsca(alt reverse) horiz  saving(hy)
    
            . twoway histogram loggnp, fraction
                    ysca(alt reverse)
                    ylabel(,nogrid)
                    xlabel(,grid gmax)       saving(hx)
    
            . graph combine hy.gph yx.gph hx.gph,
                    hole(3)
                    imargin(0 0 0 0) graphregion(margin(l=22 r=22))
                    title("Life expectancy at birth vs. GNP per capita")
                    note("Source:  1998 data from The World Bank Group")
    Thanks a lot in advance!

  • #2
    It has to do with line spacing and where each line of code ends/begins. You need to tell Stata when a line of code ends. See a couple of approaches below: all on one, using ///, or using #delimit.

    This is to run in a do-file and not interactivley.

    See
    https://www.stata.com/manuals/u16.pd...inesindo-files

    Code:
    sysuse lifeexp, clear
    
    gen loggnp = log10(gnppc)
    
    label var loggnp "Log base 10 of GNP per capita"
    
    scatter lexp loggnp, ysca(alt) xsca(alt) xlabel(, grid gmax)      saving(yx)
    
    twoway histogram lexp, fraction xsca(alt reverse) horiz  saving(hy)
    
    #delimit ;
    twoway histogram loggnp,
    fraction ysca(alt reverse)
    ylabel(,nogrid)
    xlabel(,grid gmax)      
    saving(hx) ;
    #delimit cr
    
    graph combine hy.gph yx.gph hx.gph, ///
                    hole(3) ///
                    imargin(0 0 0 0) graphregion(margin(l=22 r=22)) ///
                    title("Life expectancy at birth vs. GNP per capita") ///
                    note("Source:  1998 data from The World Bank Group")
    Last edited by Justin Niakamal; 24 May 2021, 19:09.

    Comment

    Working...
    X