BookmarkSubscribeRSS Feed
Anita_n
Pyrite | Level 9

Hi all, 

I have an access DB and I wish to write a sas macro which allows the user to directly import the data from access into sas. Is this possible at all?

I saw this code but its not working. I will appreciate any help

PROC IMPORT OUT=chemodaten
            TABLE='mySASTABLE'
            DBMS=ACCESSCS REPLACE;
   DATABASE="myAccessdb.accdb";
   RUN;

*I get this error message:;

ERROR: Failed to connect to the Server: &server.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.70 seconds
      cpu time            0.56 seconds
10 REPLIES 10
Kurt_Bremser
Super User

Your code is for use in conjunction with the SAS PC Files Server.

If SAS runs on Windows, and Access is installed there, and the accdb also resides on the same PC, then you can use DBMS=ACCESS.

Anita_n
Pyrite | Level 9

I tried using DBMS=Access but it returns this error:  

 Unable to open file mypath\&myAccessdb.accdb. It does
       not  exist or it is already opened exclusively by another user, or you need permission to view its data.

 

Anita_n
Pyrite | Level 9

It doesn't run on a server. I don't really know if it's possible to import directly from access to sas

andreas_lds
Jade | Level 19

@Anita_n wrote:

It doesn't run on a server. I don't really know if it's possible to import directly from access to sas


It is, if you have SAS Access To PC Files installed (and configured).

 

Anita_n
Pyrite | Level 9

I tried that again but I get this error

 

PROC IMPORT OUT=myoutdata
           DATATABLE='myAccesstable'
           DBMS=ACCESS REPLACE;
    DATABASE="myAccessdb.accdb";
    RUN;

ERROR: Connect: Class not registered
ERROR: Error in the LIBNAME statement.
ERROR: Connection Failed. See log for details

Kurt_Bremser
Super User

This points to a bitness issue between MS Office and SAS (32 vs. 64), or the fact that no Office(Access) is installed on the SAS host. From your previous posts I take it that Access to PC Files is installed and licensed, but you can verify that by running PROC SETINIT and PROC PRODUCT_STATUS.

 

The most robust method to transfer data between applications is the use of a textual interface file format. CSV (comma-separated), tab-separated, fixed column width are all superior to the proprietary file formats.

Anita_n
Pyrite | Level 9

Okay, I think is the issue of 64 and 32 bytes, its probably better to import using textual method

Thanks a lot

Ksharp
Super User
NO ';' in your code.

DBMS=ACCESS REPLACE;
--->
DBMS=ACCESS REPLACE

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 1441 views
  • 0 likes
  • 4 in conversation