Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Using "outsheet" and foreach again


From   "Rajesh Tharyan" <[email protected]>
To   <[email protected]>
Subject   st: RE: Using "outsheet" and foreach again
Date   Thu, 20 Apr 2006 16:37:33 +0100

Hi,

This should work

foreach file in decilenopur decilenosell {
outsheet using bra`file'.xls, comma replace
}

Here I tried using my own files decilenopur and decilenosell and it does
work..

Regards
rajesh


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Riano, Juanita
Sent: 19 April 2006 19:19
To: [email protected]
Subject: st: Using "outsheet" and foreach again

Dear all, 

I am still facing problems with the outsheet and foreach commands. 

Nick gave me a good solution except that my outsheet files don't use
numbers. My inputs are 15 datasets labeled as oilgs.dta chmcl.dta ... 
And I need to have 15 excel files with the same name plus the prefix bra
(ie  braoilgs.xls  brachcml.xls....)

This is what I have so far:

foreach x in  oilgs chmcl bresr indgs fdbev perhh hlthc rtail media
trles telcm utils banks insur finsv {
foreach file in oilgs chmcl bresr indgs fdbev perhh hlthc rtail media
trles telcm utils banks insur finsv {
use `file', clear
outsheet using bra`x'.xls , replace
}
}

However this keeps saving the first dataset "oilgs.dta"  under  15
different names braoilgs.xls brachmcl.xls 

I'd appreciate your suggestions 

Thank you!

 

---------------------------------------------
Juanita Riano
International Monetary Fund
Research Department
[email protected]
phone 202-623-5437


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index