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: RE: QUestion using -fs- package


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: QUestion using -fs- package
Date   Tue, 8 Jun 2010 22:34:10 +0200

<>

BTW, Nuno, the -creturn-s contain the string with the filename as

-di in r c(filename)-

so you do not need to save it inside the file. 


HTH
Martin


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nuno Soares
Sent: Dienstag, 8. Juni 2010 22:11
To: [email protected]
Subject: st: QUestion using -fs- package

Hi everyone,

I'm using the -fs- command to look into a directory for several files, open
them, insert a new variable with the file name, and save them. The code is
the following:

qui fs *.dta
foreach f in `r(files)' {
	use `f', clear
	cap drop file
	gen file=`f'		
	save, replace
}

However, when I run the code I get the following error code:
wscopear:  operator invalid
r(198);

Basically the gen file=`f' command is returning the above error. Any way of
doing what it is intended to do?

All the best,

Nuno


*
*   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