Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: saving stata file using macro


From   "Sergiy Radyakin" <[email protected]>
To   [email protected]
Subject   Re: st: RE: saving stata file using macro
Date   Wed, 9 Apr 2008 19:24:07 -0400

On 4/9/08, Vladimir Vakhitov <[email protected]> wrote:
> I would also suggest to include global macro names in {} (curly
> braces): "${globalname1}${globalname2}`localname3'", whenever  globals

However even in this case (with curly braces) the second global will
not be expanded if the first one ends with a backward-slash "\". But
the following works:
`"`=`"${globalname1}"' + `"${globalname2}"''"'
Here each global is expanded independently, then the results are
concatenated, then the result is used for the string value.

Best regards,
   Sergiy Radyakin


> are used  in concatenations such as file names or parts of variables'
> names. Local names are clearly delimited with quotes, whereas globals'
> are not.
>
> Vladimir.
>
>
>
> 2008/4/9, nikh 2000 <[email protected]>:
> > Thanks Nick, it worked!!
> >
> >
> >
> >
> >  On Wed, Apr 9, 2008 at 2:57 PM, Nick Cox <[email protected]> wrote:
> >  > My guess: Don't use \ as a separator within filenames.
> >  >  Use a /, even with MS Windows as your operating system.
> >  >  This is documented e.g. [U] 18.3.11.
> >  >
> >  >  Nick
> >  >  [email protected]
> >  >
> >  >  nikh 2000
> >  >
> >  >  In the following program I was trying to read a Access table using
> >  >  ODBC command. It works fine except with saving command. I want to save
> >  >  Stata file in the same name as Access file. When I used method-1 it
> >  >  didn't work. Method-2 works fine. But I don't want to add any prefix
> >  >  in the filename I saved. Any Idea how I could save without any
> >  >  prefix?. I have to convert and save many Access tables into Stata
> >  >  format.
> >  >
> >  >  Method-1:
> >  >  cap prog drop readdata
> >  >  prog def readdata
> >  >         clear
> >  >         odbc load, dsn("MS Access Database; DBQ=$acdata_sc")
> >  >  table("`1'") lower
> >  >         count
> >  >         save $data_sc\`1',replace
> >  >  end
> >  >
> >  >  readdata        assetstatus
> >  >
> >  >  **
> >  >  . readdata        assetstatus
> >  >   3351
> >  >  invalid '`'
> >  >  r(198);
> >  >
> >  >
> >  >  Method-2:
> >  >  cap prog drop readdata
> >  >  prog def readdata
> >  >         clear
> >  >         odbc load, dsn("MS Access Database; DBQ=$acdata_sc")
> >  >  table("`1'") lower
> >  >         count
> >  >         save x`1',replace
> >  >  end
> >  >
> >  >  . readdata        assetstatus
> >  >   3351
> >  >  (note: file C:\xassetstatus.dta not found)
> >  >  file C:\xassetstatus.dta saved
> >  >
> >  >  *
> >  >  *   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/
> >  >
> >  *
> >  *   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/
> >
>
>
>
> --
> __________________
> Volodymyr Vakhitov
> [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/
>
*
*   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