Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: local macros & saving in directory


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: local macros & saving in directory
Date   Thu, 27 Jun 2002 08:44:23 +0100

Daniel Muller started a thread with
>
> I coded:
>
> ----
> version 7
> local var "somevar"
>
> ... code in terms of `var'
>
> out `var's using "d:\stata\export\`var's.asc", runtogether replace
> ----
>
> However, the file is saved in dir <d:\stata> under the name
> <export`var's.asc>, not as I expected in dir <d:\stata\export> as
> <somevars.asc>.
>
> Where is my mistake? Why does Stata strip off the slash before `var'?
>

As pointed out by Zhiqiang Wang and Antoine Terracol,
this behaviour arises because in Stata the meaning of \ as an escape
character
overrides its meaning as a separator in Windows file
specifications whenever \ precedes a left quote `.
It is not a bug.

The more general principle is that Stata is designed,
as far as possible, to work the same across the platforms
on which is supported, currently Windows, various flavours
of Unix (including Linux) and Macintosh, an admirable principle
but one not always possible to satisfy down to every last detail.
In this case, \ clearly has a special meaning within Windows,
but there is a clash in the circumstance identified by Daniel,
as is documented at [U] 21.3.9.

A good fix for this problem is to get into a general habit
of using / as a separator within Stata. This may seem
strange to Windows users, but Stata will happily translate
whenever it interacts with Windows on your behalf.

Nick
[email protected]

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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