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: Looping over a range of observations


From   Francesca Colantuoni <[email protected]>
To   [email protected]
Subject   st: Looping over a range of observations
Date   Fri, 23 Aug 2013 12:48:17 -0400

Hello Statalist!
I am working with a panel data set. I would like to create and save
graphs that show
histograms of a variable (price1) per each store in the data set. I
have many stores (900), therefore if I do:

histogram price1, by (store)

each histogram would be microscopic and I would not be able to see anything.

So, I tried with:

histogram price1 in 1/2120, by (store)

which allows me to visualize histograms for the first 10 stores only,
and this works way better.

Now, though, I would like to create a loop that increments the range
of observations and  creates a number of graphs containing 10
histograms each.

I was trying with something like:

forvalues i=1/2120 {
histogram price1 in `i', by(store)
graph save graph "graph1.gph", replace
}

Of course I need to nest the loop to update the graphs and I still
need to increment the range of observations, but for the moment, I
would like to get some help to  figure out the first part, because
even if the code runs no problem, the graph I get is not what I want
(it's only one histogram with one bar).

Kindest Regards,

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


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