Help using Base SAS procedures

Reading a data file using SAS ODBC

Reply
Contributor
Posts: 34

Reading a data file using SAS ODBC

how to read a .dat file (data file) which i couldnt read as a text file???using

Super User
Posts: 3,250

Re: Reading a data file using SAS ODBC

Posted in reply to BharathBandi

ODBC is mostly used for reading database tables not data/text files. What does the .DAT file look like when viewed in a text editor? Does it have aligned rows and columns or is a delimiter used to separate columns?

What issues are you having reading it?

Contributor
Posts: 34

Re: Reading a data file using SAS ODBC

It is not opening in text editor, when tried data is crashed.

I basically want to read a .dat file that is copied from exchequer database.

Thank you

Super User
Posts: 3,250

Re: Reading a data file using SAS ODBC

Posted in reply to BharathBandi

How big is the file? Most likely it is the file size that is causing the text editor problems.

You could try reading a few records in SAS to see what the record layout is by writing the first 5 records to the SAS log:

data test;

  infile "YourFileName.dat" obs = 5;

  input;

  put _infile_;

run;

Contributor
Posts: 34

Re: Reading a data file using SAS ODBC

Files are quite small something around 100 KB.

These files are extracted from Pervasive DB which has a default extension .Dat. which cannot be opened in text editor.

The only way I can read this file is through ODBC connection.

Super User
Posts: 7,761

Re: Reading a data file using SAS ODBC

Posted in reply to BharathBandi

So you can already open the data in, say, Excel via the ODBC connection?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 34

Re: Reading a data file using SAS ODBC

Posted in reply to KurtBremser

Thank you all . We need to buy Btrieve odbc drivers, it solves the problem. Smiley Happy

Super User
Posts: 7,761

Re: Reading a data file using SAS ODBC

Posted in reply to BharathBandi

Is it copied or exported from the database?

Is there any documentation about the structure?

If not, return to sender.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 5,424

Re: Reading a data file using SAS ODBC

Posted in reply to BharathBandi

If I recall it correctly, I think.dat was the default extension for export/backup-files in (very) old versions of SQL Server.

If this is such file, you can't import it either way (ODBC nor text file import).

Verify your source, before trying to import it.

Data never sleeps
Contributor
Posts: 34

Re: Reading a data file using SAS ODBC

Yes it is default extension and these files are extracted from pervasive db.

Super User
Posts: 5,424

Re: Reading a data file using SAS ODBC

Posted in reply to BharathBandi

Don't think this is a SAS question. How you can be able to access this data via ODBC is a question for Actian/Pervasive DB.

Once you secured ODBC access to your source data, then you can go to SAS and try to connect.

Data never sleeps
Super User
Posts: 3,250

Re: Reading a data file using SAS ODBC

Posted in reply to BharathBandi

You will also need the SAS product SAS/ACCESS to ODBC both installed and licensed if you wish to extract ODBC data using SAS code.

Ask a Question
Discussion stats
  • 11 replies
  • 394 views
  • 0 likes
  • 4 in conversation