Statalist


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

Re: st: RE: saving stata file using macro


From   "nikh 2000" <[email protected]>
To   [email protected]
Subject   Re: st: RE: saving stata file using macro
Date   Wed, 9 Apr 2008 15:02:03 -0600

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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index