How to import a .bak file of SQL Server to SAS?

Accepted Solution Solved
Reply
Regular Contributor
Posts: 166
Accepted Solution

How to import a .bak file of SQL Server to SAS?

[ Edited ]

Hello everybody,

Is there any way to import a .bak file of SQL Server into SAS?

 

Thanks in advance.


Accepted Solutions
Solution
‎11-29-2017 11:30 AM
Super User
Posts: 23,235

Re: How to import .bak file?

Posted in reply to aminkarimid

IIRC it's usually a txt file that has the code to create the data set. 

Open it as a text file using your favorite text editor (NotePad++  etc). 

 

The code usually doesn't won't translate directly into SAS but the conversion to SAS SQL should be relatively straightforward. 

 

Python can read it directly without converting.


You can use Python within SAS Viya so that's another option.

 

 

View solution in original post


All Replies
Super User
Posts: 9,868

Re: How to import .bak file?

[ Edited ]
Posted in reply to aminkarimid

.bak files are often automatically created backups when a file is changed, so it is necessary to know how the orignal file is structured or what type it is. Then you'll know if you can use proc import or if you can write a data step according to the specifications.

 

See https://en.wikipedia.org/wiki/Bak_file

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Regular Contributor
Posts: 166

Re: How to import .bak file?

Posted in reply to KurtBremser
This is a data base which is backed up from SQL server. DBMS has some advantages than file system (like decreased size). Python can read it directly without converting.
Super User
Posts: 9,868

Re: How to import .bak file?

Posted in reply to aminkarimid

If you don't want to use a direct connection with SAS/ACCESS (to RDBMS or via ODBC), then you are better off by exporting from SQL Server to a text-based format like csv, and reading with a data step.

Parsing a proprietary format will be very hard, if possible at all.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Solution
‎11-29-2017 11:30 AM
Super User
Posts: 23,235

Re: How to import .bak file?

Posted in reply to aminkarimid

IIRC it's usually a txt file that has the code to create the data set. 

Open it as a text file using your favorite text editor (NotePad++  etc). 

 

The code usually doesn't won't translate directly into SAS but the conversion to SAS SQL should be relatively straightforward. 

 

Python can read it directly without converting.


You can use Python within SAS Viya so that's another option.

 

 

New Contributor
Posts: 3

Re: How to import .bak file?

Posted in reply to aminkarimid

I might be wrong, but I didn't know SAS created .bak files of any kind.

 

What is/was the file originally? Has someone changed the extension as part of a backup routine, or is this a file created by a SAS utility as part of an underlying backup routine?

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 323 views
  • 1 like
  • 4 in conversation