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: Load data using macro


From   Sergiy Radyakin <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Load data using macro
Date   Thu, 13 Jun 2013 10:47:35 -0400

As William just wrote we need to see exactly what's going on.
Hypothetically the symptoms you describe recall the chdir-syndrom such
as in:

save "mydata"
......whataver code.....
...chdir .\dataIneednow\
......whatever code......
use "mydata"

With the above:
    1)you will see the file on your disk, and
    2) you will get an error when trying to load the data.

Solution is to check the code for changing the current directory, and
perhaps try to use full absolute paths if that's possible until you
find the source of a problem.

Use command pwd in your file to write to output what is the current
directory at the moment, then review the logs.


Other explanations are possible, but sound more complicated.

Hope this helps, Sergiy






On Thu, Jun 13, 2013 at 10:19 AM, William Buchanan
<[email protected]> wrote:
> Hi Gareth,
>
> Your question is too vague for anyone to provide a direct answer to your question.  There could be several potential problems with the code not working, but without showing _EXACTLY_ what you typed and _EXACTLY_ what Stata returned, there isn't a way to help.  You could try to use -ls- to see if the file exists in the current directory, you may also want to reference the file name with compound double quotes : use `"`depvar'.dta"', or there could be several other issues causing the failure.  Either way, the more information you are able to provide the easier it is for others to help you.
>
> For example:
>
> sysuse auto
> loc depvar price
> save `depvar'.dta, replace
> use `depvar', clear
>
> Does exactly what it is that you said you are having difficulty doing.
>
> HTH,
> Billy
>
>
> On Jun 13, 2013, at 9:57 AM, G. Anderson <[email protected]> wrote:
>
>> Hi,
>>
>> I am able to save files using the name of a variable in a macro (in this case my dependent variable
>>
>> So when I type
>>
>> save `depvar', replace
>>
>> it saves a file with the name of the dependent variable as my filename.
>>
>> Unfortunately when loading data
>>
>> use `depvar'
>> doesn't work. Any ideas how you can load data using names defined by macros?
>>
>>
>> Thanks
>>
>> Gareth
>> *
>> *   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index