Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

st: Re:Histogram Axis labels

From   Michael Stewart <>
To   statalist <>
Subject   st: Re:Histogram Axis labels
Date   Sun, 9 Jun 2013 23:37:01 -0400

Dear Statalist users ,

I am trying to draw histograms for my variables and  due to large
number of  variables, am using foreach command along grss (exploratory
data analysis). I have run into problem with x axis labels in
histograms and n  was trying to see if anyone has

My code is as follows

foreach x of varlist *{
keep  PAT_ID  `x'
duplicates drop
sum `x' ,d
tabulate `x'
tabulate `x', sort
tabulate `x', plot sort
grss quantile `x'
grss hist  `x',discrete percent addlabel gap(20)  xlabel(, valuelabel)

Problem-1: As different variables have different ranges, how can I get
Stata to show value  for every bar on x axis

Eg: If I am  drawing histogram for years 2001-2007 and I have
observations for every year,stata will show bars corresponding to each
year (with percent value on top of it) ,  but will not show the
corresponding year on x axis ... it might show  2001, 2003, 2005 2007
on x axis but not 2001 2002 2003  2004 2005 2006 2007(corresponding to
the bar)  .

Its easy to do it individually(by adjusting the number of ticks) but
in foreach loop with number of variables, with varying ranges( Eg :
years(range: 2001 - 2010), visits_per_year(range: 1 - 20) etc ) , how
can I program stata to adjust the number of ticks and yet show all
values on the x asis

Thank you ,
Yours Sincerely,
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index