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, statalist.org is already up and running.


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

Re: st: Append within a loop


From   Eric Booth <eric.a.booth@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Append within a loop
Date   Thu, 12 Jul 2012 18:53:30 -0500

<>


*****************
	clear
	sa master.dta, replace emptyok
foreach i in Female Male{
foreach k in 11 12 13 14 15 16 17 21 22 23 24 25 26 27 28 29 31 32 33 35 41
42 43 50 51 52 {
foreach l in 0a3 4a8 9a11 12+ {
use "$directory\UF `k'\variavel ocupacao\Grupo `l'\data_`i'_`k'_`l'.dta", clear
	append using master.dta
	sa master.dta, replace
}
}
}
u master.dta, clear
*****************




On Jul 12, 2012, at 6:39 PM, Camila Mendes wrote:

> Hi all,
> 
> I've created some data in separate folders using a loop, and now I wish to
> append all the files (over i, k and l).
> 
> Can anyone help me?
> 
> foreach i in Female Male{
> foreach k in 11 12 13 14 15 16 17 21 22 23 24 25 26 27 28 29 31 32 33 35 41
> 42 43 50 51 52 {
> foreach l in 0a3 4a8 9a11 12+ {
> use "$directory\UF `k'\variavel ocupacao\Grupo `l'\data_`i'_`k'_`l'.dta",
> clear
> }
> }
> }
> 
> Thanks,
> 
> Camila
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/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/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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