Automating Import from SAS

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

BCNAV
Posts: 40
Joined: Tue Oct 31, 2017 9:06 am

Automating Import from SAS

Postby BCNAV » Fri Nov 17, 2017 1:53 pm

I have some SAS databases that are regularly made that I want to convert into an EViews database. To start I have:


Code: Select all

!year=2000+@right(@date,2)   

wfcreate test m 2000 !year
import R:\Eviews\SAS_Data\nav_data_all_ts.sas7bdat @freq m 2000
delete date


Now, I am unsure how to setup the database and copy all the variables from the workfile called test (except for c and resid) into the database. This database should be able to be overwritten every month. I just want to be able to open the program and run it to update with new data. So:

1. Syntax to create the database without any "database already exists" errors (can be able to overwrite).
2. Copy variables into it.

Or do I even need to use a workfile at all? Can there be a direct import to a databse?

Thanks!

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13307
Joined: Tue Sep 16, 2008 5:38 pm

Re: Automating Import from SAS

Postby EViews Gareth » Fri Nov 17, 2017 2:20 pm

Use dbdelete to delete the database, dbcreate to create one and then fetch to send data to it.

Yes, you have to go to a workfile before the db.
Follow us on Twitter @IHSEViews

BCNAV
Posts: 40
Joined: Tue Oct 31, 2017 9:06 am

Re: Automating Import from SAS

Postby BCNAV » Sat Nov 18, 2017 7:54 am

Here is what I ended up with....any suggestions or issues?

Code: Select all


'Database should have up to current year of data in it
!year=2000+@right(@date,2)   

'Where the database is located
%dbname="R:\Eviews\Databases\Testing\navts_test.edb"

'If the database exists, delete it, since we want to rewrite it with new data
if @fileexist(%dbname) then
   dbdelete %dbname
endif

'Workfile must be made to store the imported data before exporting to EViews database
wfcreate R:\Eviews\Workfiles\TMP\datatmp m 2000 !year
import R:\Eviews\SAS_Data\nav_data_all_ts.sas7bdat @freq m 2000
delete date  'We don't want the SAS made date

'Create the database to store the new time series data
dbcreate {%dbname}

'Copy all data (*) to the database
copy(o) * {%dbname}::

'Delete the constant and residual place holders from the database, as they were copied
delete {%dbname}::c
delete {%dbname}::resid

wfsave R:\Eviews\Workfiles\TMP\datatmp.wf1
close datatmp



Return to “Programming”

Who is online

Users browsing this forum: No registered users and 27 guests