Bookmark and Share

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

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

st: Using a saved results in -ylabel-

From   "MacLennan, Graeme" <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: Using a saved results in -ylabel-
Date   Tue, 9 Aug 2011 17:12:16 +0100

Dear all, 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.
Regards, Graeme.

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

*   For searches and help try:

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