Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: RE: Using a saved results in -ylabel-


From   "MacLennan, Graeme" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: RE: RE: Using a saved results in -ylabel-
Date   Tue, 9 Aug 2011 21:34:24 +0100

Nick, firstly noted re ssc, secondly thank you this does exactly what I need.
Graeme.

****
Nick said:

-mmodes- is from SSC. Please remember to explain where user-written programs you refer to come from.

r(N), left behind by -mmodes-, has a local macro persona which you can invoke:

foreach var  of varlist var* {
        mmodes `var'
        histogram `var', discrete freq xlabel(1(1)9) width(1) start(1) ///
               xtitle("`var' ") ylabel(0(5)`r(N)')
        graph export `var'.png , replace
}

Nick
[email protected]

MacLennan, Graeme

how do I use a saved value in the -ylabel- option of -histogram-?

I would like to plot a series of histograms, always with the y-axis stepping up 5s. (I have looked for fixed widths but could only find this for x-axis, I have missed something obvious then great, let me know).  The data are a series of Likert style items from 1 to 9. Clearly I can specify this from variable to variable, but I want to be able to automate .  The problem is that the mode changes from variable to variable so I want to do something like  -ylabel(0(5)maximum value) where "maximum value" is the frequency of the mode (and therefor the maximum value on the y-axis of the histogram). I had thought to use the -mmodes- package from ssc which returns the frequency of the mode in r(N) to something like:


foreach var  of varlist var* {
        mmodes `var'
        histogram `var', discrete freq xlabel(1(1)9) width(1) start(1) xtitle("`var' ") ylabel(0(5)r(N))
        graph export `var'.png , replace
}

However the error I get is " invalid label specifier, :  0(5)r(N): "  I have tried using a local macro, but that does not work for me either.


The University of Aberdeen is a charity registered in Scotland, No SC013683.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index