How can I read a SAS dataset?

You'll need to have a running SAS session to act as a data server. You can then access the SAS data using ODBC, see the SAS ODBC drivers guide To get the local SAS ODBC server running, you need to: Define your SAS ODBC server setup at described in the SAS ODBC drivers guide. In the example that follows, I'll connect to a server that is set up with the name "loclodbc Add an entry in your services file, (C:\WINDOWS\system32\drivers\etc\services), like this: loclodbc 9191/tcp set the port number (here: 9191) so that it fits into your local setup.

The name of the service "loclodbc" must match the server name as defined in the ODBC setup. Note that the term "Server" has nothing to do with the physical host name of your PC Your SAS ODBC server is now ready to run, but is has no assigned data resources available. Normally you would set this in the "Libraries" tab in the SAS ODBC setup process, but since you want to point to data sources "on the fly", we omit this From your client application you can now connect to the SAS ODBC server, point to the data resources you want to access, and fetch the data The way SAS points to data resources is through the concept of the "LIBNAME".

A libname is a logical pointer to a collection of data Thus LIBNAME sasadhoc 'C:\sasdatafolder assigns the folder "C:\sasdatafolder" the logical handle "sasiodat If you from within SAS want access to the data residing in the SAS data table file "C:\sasdatafolder\test. Sas7bdat", you would do something like this: LIBNAME sasadhoc 'C:\sasdatafolder'; PROC SQL; CREATE TABLE WORK. Test as SELECT * FROM sasadhoc.

Test ; QUIT So what we need to do is to tell our SAS ODBC server to assign a libname to C:\sasdatafolder, from our client application. We can do this by sending it this resource allocation request on start up, by using the DBCONINIT parameter I've made some sample code for doing this. My sample code is also written in the BASE SAS language.

Since there are obviously more clever ways to access SAS data, than SAS connecting to SAS via ODBC, this code only serves as an example You should be able to take the useful bits and create your own solution in the programming environment you're using SAS ODBC connection sample code: PROC SQL; CONNECT TO ODBC(DSN=loclodbc DBCONINIT="libname sasadhoc 'c:\sasdatafolder'"); CREATE TABLE temp_sas AS SELECT * FROM CONNECTION TO ODBC(SELECT * FROM sasadhoc. Test); QUIT The magic happens in the "CONNECT TO ODBC..." part of the code, assigning a libname to the folder where the needed data resides.

You'll need to have a running SAS session to act as a data server. You can then access the SAS data using ODBC, see the SAS ODBC drivers guide. To get the local SAS ODBC server running, you need to: Define your SAS ODBC server setup at described in the SAS ODBC drivers guide.In the example that follows, I'll connect to a server that is set up with the name "loclodbc".

Add an entry in your services file, (C:\WINDOWS\system32\drivers\etc\services), like this: loclodbc 9191/tcp ...set the port number (here: 9191) so that it fits into your local setup. The name of the service "loclodbc" must match the server name as defined in the ODBC setup. Note that the term "Server" has nothing to do with the physical host name of your PC.

Your SAS ODBC server is now ready to run, but is has no assigned data resources available. Normally you would set this in the "Libraries" tab in the SAS ODBC setup process, but since you want to point to data sources "on the fly", we omit this. From your client application you can now connect to the SAS ODBC server, point to the data resources you want to access, and fetch the data.

The way SAS points to data resources is through the concept of the "LIBNAME". A libname is a logical pointer to a collection of data. Thus LIBNAME sasadhoc 'C:\sasdatafolder'; assigns the folder "C:\sasdatafolder" the logical handle "sasiodat".

If you from within SAS want access to the data residing in the SAS data table file "C:\sasdatafolder\test. Sas7bdat", you would do something like this: LIBNAME sasadhoc 'C:\sasdatafolder'; PROC SQL; CREATE TABLE WORK. Test as SELECT * FROM sasadhoc.

Test ; QUIT; So what we need to do is to tell our SAS ODBC server to assign a libname to C:\sasdatafolder, from our client application. We can do this by sending it this resource allocation request on start up, by using the DBCONINIT parameter. I've made some sample code for doing this.

My sample code is also written in the BASE SAS language. Since there are obviously more clever ways to access SAS data, than SAS connecting to SAS via ODBC, this code only serves as an example. You should be able to take the useful bits and create your own solution in the programming environment you're using... SAS ODBC connection sample code: PROC SQL; CONNECT TO ODBC(DSN=loclodbc DBCONINIT="libname sasadhoc 'c:\sasdatafolder'"); CREATE TABLE temp_sas AS SELECT * FROM CONNECTION TO ODBC(SELECT * FROM sasadhoc.

Test); QUIT; The magic happens in the "CONNECT TO ODBC..." part of the code, assigning a libname to the folder where the needed data resides.

Actually, you don't need a running SAS session; the ODBC driver will automatically launch one for you. However, there's no easy way to programmatically create the ODBC configuration, so that has to be manually configured. Which is a problem, since you can't just load an arbitrary dataset.

– Chris B. Mar 11 '10 at 20:15 By arbitrary, you probably mean "located anywhere, with any name"...? Or is it given as a parameter? – Martin Bøgelund Mar 11 '10 at 21:46 Located anywhere, with any name.

– Chris B. Mar 12 '10 at 0:03 I'm certain this can be done. If you can write the location of the SAS data file to a file at runtime, from your calling application, SAS can be set to read this file upon ODBC start up, and make assignments in order to provide the data via ODBC.

I'll look into this. – Martin Bøgelund Mar 12 '10 at 8:38.

I have never tried oview.co.uk/dsread/, but it might be what you're looking for: "a simple command-line utility for working with datasets in the SAS7BDAT file format. " But do note "This software should be considered experimental and is not guaranteed to be accurate. You use it at your own risk.It will only work on uncompressed Windows-format SAS7BDAT files for now.

I think you might be able to use ADO, See the SAS support site for more details. Disclaimer: I haven't looked at this for a while I'm not 100% sure that this doesn't require additional licensing I'm not sure if you can do this using Python.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions