+ Reply to Thread
Results 1 to 2 of 2

How to call SAS program via VBA

Hybrid View

VAer How to call SAS program via... 10-05-2023, 02:24 PM
ranman256 Re: How to call SAS program... 10-05-2023, 02:34 PM
  1. #1
    Forum Contributor VAer's Avatar
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    803

    How to call SAS program via VBA

    Now there are two steps:

    1. Using VBA to create a table, data source is from another excel file. I wrote the VBA program.
    2. Run SAS program (SAS application) to load data into database. Someone else wrote SAS program.

    Question: How to call SAS program within Excel? So that I don't have to open SAS app.

    Thanks.
    Last edited by VAer; 10-05-2023 at 02:37 PM.

  2. #2
    Valued Forum Contributor ranman256's Avatar
    Join Date
    07-29-2012
    Location
    Kentucky
    MS-Off Ver
    Excel 2003
    Posts
    1,190

    Re: How to call SAS program via VBA

    dont need step 1 if you can import data from SAS.

    do you have an ODBC for SAS? This allows you to connect to the SAS table, then the table can reside in Access.
    or
    use the connection code to connect into Access or Excel.

    something like:
    Public Sub CopyRstIntoXL()
    Dim con As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim DB
    Dim vProvid
    
    Set con = New ADODB.Connection
    Set rs = New ADODB.Recordset
    
    db = "MyDB" 
    vProvid = "SASOLEDB"    'some sort of SAS driver?
     
    With con
        .Provider = vProvid
        .Open "Data Source=" & DB
    End With
     
    rs.Open "select * from tMyTable", con
    
    ActiveWorkbook.Worksheets("Sheet1").Range("A1").CopyFromRecordset rs
    
    rs.Close
    con.Close
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 8
    Last Post: 02-16-2017, 09:11 AM
  2. VBA-How to program sizing and placing Excel window at the start of the program
    By dr.prakash in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-17-2013, 11:45 PM
  3. Program Flow Stops and Will not Return After Call
    By SDruley in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-03-2010, 08:11 PM
  4. call another program
    By dHouge in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-05-2008, 04:40 AM
  5. Call external program in Excel Macro
    By Ivan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-23-2006, 07:00 AM
  6. Unable to call external program/dll
    By pipo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-30-2005, 03:11 AM
  7. Call Schedule Program in Excel
    By raddoc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-08-2005, 07:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1