DATA Step, Macro, Functions and more

Open an MS Access database from SAS

Reply
Contributor
Posts: 23

Open an MS Access database from SAS

This is kind of a wild question, is there SAS code that can automatically open (not assigning it as a library) an existing ms access database file?

Super User
Posts: 10,500

Re: Open an MS Access database from SAS

The X command, if enable in your install, will start any program you can run from a command prompt. Pass the name of the file the program is to open and that should work. You will likely need to have the full path the executeable for Access and use the full path to the file.

Contributor
Posts: 23

Re: Open an MS Access database from SAS

I'm not sure I follow.  Here is what Im trying to do: I have a report that uses SAS to pull and organize the data.  Once the program completes, it dumps it into an access database a VBA script will run and produce the excel output.  Without having to wait for the SAS program to finish and then clicking on the access database, I would like the SAS program to automatically open the access database and begin running the VBA code that I have. At this point, I just need SAS to somehow open my existing ms access file from a specific location where it resides.  My ultimate goal down the road is to code and automate the entire process in SAS.

Super User
Posts: 3,105

Re: Open an MS Access database from SAS

I think it would be a lot easier for SAS to send the required output to Excel directly rather than trying to "daisy chain" it via Access. What is this output?

Contributor
Posts: 23

Re: Open an MS Access database from SAS

It is a dataset of about 1500 records.  It would need to be dumped into an existing excel template, run the VBA macros within excel then save as a new file.

Super User
Posts: 17,819

Re: Open an MS Access database from SAS

Yes, you can, this is how it would work for Excel. You can change the path to Excel with the path to Access application and then the path to the file with the path to the DB.

How to pass the command to run the macro I'm not sure, can you set it to run whenever the DB opens?

options noxwait noxsync;
x '"C:\Program Files (x86)\Microsoft Office\Office14\Excel.exe" "C:\_localdata\Template.xlsx"';
Super User
Posts: 17,819

Re: Open an MS Access database from SAS

Is it just a proc export to the template or does it need to go to specific cells? Otherwise this is relatively easy. I wrote an unclear paper on it here: http://www.sas.com/content/dam/SAS/en_ca/User%20Group%20Presentations/Edmonton-User-Group/FareezaKhu...
Ask a Question
Discussion stats
  • 6 replies
  • 234 views
  • 0 likes
  • 4 in conversation