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]

Re: st: loop


From   Chamara Anuranga <[email protected]>
To   [email protected]
Subject   Re: st: loop
Date   Tue, 22 Oct 2013 14:37:48 +0530

Dear Camara,

You have not mention the Stata version you are using. If it is 12 or
13 I would suggest collapse the data and export the data to excel
sheet. If you use table command you have to copy each table.
This question is easy and straight forward. If you check the loop
command you would easily figure it out

foreach num of numlist 1/50 {
   table indicator2  year, c(mean value), if country==`num'  &
year>=2009 & year<.
}

solution 2.
this does not need loop command. you can run the collapse command and
then list the data. Make sure you save your data before collapse
command.
keep  if year>=2009 & year<.
 collapse (mean) value, by (indicator2 country)


Thanks,
Chamara


On Tue, Oct 22, 2013 at 2:14 PM, Abu Camara <[email protected]> wrote:
> Dear Statalist,
>
> I would like to write the following code in the form of a loop for 50
> countries coded from (1 to 50)
> instead writing the below code 50 times. Any help would be appreciated.
>
>
> table indicator2  year, c(mean value), if country==1  & year>=2009 & year<.
>
> --
> Best Wishes,
> Abu Camara
> *
> *   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/
*
*   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