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: Creating filename variable
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Creating filename variable
Date
Tue, 25 Mar 2014 17:44:17 +0000
Right. For a convenience wrapper, see -fs- (SSC). The name -fs- is by
analogy with -ds-. Grabbing the name -files- would have been too much.
Nick
[email protected]
On 25 March 2014 17:27, Nick Winter <[email protected]> wrote:
> And to populate <filenames>:
>
> local filenames : dir "." files "*.dta"
> foreach fn of local filenames {
> ...
>
> }
>
>
>
> On 3/25/2014 11:46 AM, Nick Cox wrote:
>>
>> foreach <filename> in <filenames> {
>> <get>
>> <do>
>> gen file_name = "`filename'"
>> <put>
>> }
>>
>>
>> Nick
>> [email protected]
>>
>>
>> On 25 March 2014 15:43, Anya Burton <[email protected]> wrote:
>>>
>>> I'm creating a do file that loops through files in a directory formatting
>>> them. I need to extract the name of each file and save it as variable
>>> (file_name) within that file. Could anyone advise me on how to do this?
>>>
>>> Many thanks in advance!
>>>
>>> Anya
>>> *
>>> * 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/
>>
> *
> * 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/