Statalist


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

st: saving stata file using macro


From   "nikh 2000" <[email protected]>
To   [email protected]
Subject   st: saving stata file using macro
Date   Wed, 9 Apr 2008 14:36:59 -0600

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/



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