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: Files, Directories and Macros


From   Andrés Castañeda <[email protected]>
To   [email protected]
Subject   st: Files, Directories and Macros
Date   Tue, 31 Jan 2012 10:01:47 -0500

Dear Stata list,

I have a problem using macros to organize files. Let’s say that in the
folder "C:\Temp" I have a UNIQUE dta file named “example.dta”. I need
to call this file in Stata by using macros.
*  First I define a global that contains the directory path and a
local with the name of the file (I have tried with both globals, both
locals and the other way around but the results is still the same)
global dir "C:\Temp”
local data: dir "$dir" files "*.dta"

* If I check with the display option in seems to work.
 di "$dir"
C:\Temp

 di `data'
example.dta

 di "$dir\"`data'
C:\Temp\example.dta


*  But if I am going to use the file following the same structure than
above I got the following error:
 use "$dir\"`data', clear
invalid '"example.dta'

I have tried to do this in several ways; using double quotes, compound
double quotes, single quotes, among others. I don’t know what the
right combination of quotes is in order to get the file….

Thank you so much.






--
___

Best,


Andrés Castañeda
World Bank, LAC-PREM
Research Associate
[email protected]
Tel 1(202) 677 - 8971
1850 I st, NW, Washington, DC.

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