Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE: Re: Using backslash in macros


From   Steinar Fossedal <[email protected]>
To   [email protected]
Subject   Re: st: RE: Re: Using backslash in macros
Date   Thu, 7 May 2009 20:28:42 +0200

Thank you both for your answeres. Using slashes instead of backslashes
solves my problem. Sorry about the SAS-jargon that slipped my tongue,
a mental injury from using SAS at work.

Earlier, I've been arguing hard to use Stata for analyses, but
eventually found it somewhat lacking when it comes to database
communication. Updating databasetables using ODBC seems to be very
slow and cumbersome, as is adding variables to an existing table. This
might very well be the fault of the SQL Server I've been using (or my
queries), but nevertheless I'm curious - is database integration a
topic Statacorp is looking to improve in the near future?

Cheers,
-Steinar

2009/5/7 Nick Cox <[email protected]>:
> Martin referred you to an article by me, which is certainly pertinent. Note that this issue is thoroughly ventilated in the manuals at [U] 18.3.11.
>
> The bottom line for you is to use forward slashes for Windows filepath delimiters. Stata will happily translate.
>
> N.B. what you call macrovariables are in Stata called local macros.
>
> Nick
> [email protected]
>
> Martin Weiss
>
> http://www.stata-journal.com/article.html?article=pr0042
>
> Steinar Fossedal
>
>> I'm having problems combining macrovariables when the first macro ends
>> with a backslash. Apparently, the end backslash is not included, and
>> the following macro is not unpacked. This is not a problem if the two
>> macros do not follow each other directly. The example below
>> illustrates the problem:
>>
>>
>> local indatadir e:\data\stata10\
>> local table mytable
>>
>> di "indatadir <`indatadir'>"
>> di "table <`table'>"
>>
>> // Backslash missing, macro `table' not unpacked:
>> di "`indatadir'`table'"
>> // Backslash ok and `table' unpacked when adding a sign (any letter)
>> behind the first macro:
>> di "`indatadir'_`table'"
>>
>>
>>
>> The result is as follows:
>>
>> local indatadir e:\data\stata10\
>>
>> . local table mytable
>>
>> .
>> . di "indatadir <`indatadir'>"
>> indatadir <e:\data\stata10\>
>>
>> . di "table <`table'>"
>> table <mytable>
>>
>> .
>> . // Backslash missing, macro `table' not unpacked:
>> . di "`indatadir'`table'"
>> e:\data\stata10`table'
>>
>> . // Backslash ok and `table' unpacked when adding a sign (any letter)
>> behind the first macro:
>> . di "`indatadir'_`table'"
>> e:\data\stata10\_mytable
>>
>>
>>
>> What is the reason behind this, and how can I work around it?
>
> *
> *   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index