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: Append within a loop


From   Eric Booth <[email protected]>
To   [email protected]
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index