*
*  HISTSCAT
*    Computes and graphs histogram for a single series
*
*  Note: Must do an ALLOCATE before sourcing in the procedure
*  Syntax:
*   @HISTSCAT(option) series
*
*  Option:
*    NBAR=number of "bars" in the histogram
*
*  Note:  You may want to use "GRPARM AXISLABEL size" instruction
*         to adjust size of axis labels.
*
*  Revision schedule:
*    12/96 Written by Estima
*
*
procedure histscat series
type series series
option integer nbar 10
local integer ibar
local real increment low high minvalue vmaxval
local series value counts tmp xaxis
local vector[strings] xlab
local string meanval
/*
**  Figure out the starting value and increment
*/
compute minvalue = %minvalue(series)
compute increment = 1.01 * ( %maxvalue(series) - minvalue ) / nbar
set counts 1 nbar = 0.0
set value 1 nbar = 0.0
dim xlab(nbar)
do ibar = 1, nbar
    compute low = minvalue + (ibar-1.0) * increment
    compute high = low + increment
    *disp low high
    set tmp = (series.ge.low .and. series.lt.high)
    stats(noprint) tmp /
    compute value(ibar) = (low + high) / 2.0
    compute counts(ibar) = %mean * %nobs
    disp(store=meanval) ##.## value(ibar)
    compute xlab(ibar) = meanval
end do
set xaxis 1 nbar = t
com vmaxval = %maxvalue(value)+1.0
scatter(vlabel='Counts',hlabel='Mean Values of Intervals',style=symbol,xlabels=xlab) 1
# xaxis counts 1 nbar
end


