BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
vibeznstuff
Fluorite | Level 6

I would like to import data from SAS into excel using ADO and VBA within excel. Does anyone know if it is required that SAS be installed on the client accessing the SAS data or if the SAS Excel plug-in needs to be present?

1 ACCEPTED SOLUTION

Accepted Solutions
FriedEgg
SAS Employee

To connect to a remote SAS server you need to install the SAS Integration Technologies client.  This will enable you to use com objects to connect to the remote workspace server and collect data using ADO.

View solution in original post

5 REPLIES 5
SASKiwi
PROC Star

The SAS ADO Excel plug-in needs to be installed on the PC where Excel is being used.

ADO needs to connect with either a local SAS server, in which case SAS needs to be installed on the PC, or to a remote SAS server, in which case SAS does not need to be installed on the PC.

vibeznstuff
Fluorite | Level 6

I would like to connect to a remote SAS server. If I understand correctly, I will still need the SAS ADO plug-in but will not need SAS installed on my PC?

Thanks for the quick response!

FriedEgg
SAS Employee

To connect to a remote SAS server you need to install the SAS Integration Technologies client.  This will enable you to use com objects to connect to the remote workspace server and collect data using ADO.

vibeznstuff
Fluorite | Level 6

Thanks, accomplished what I wanted to. Appreciate it!

FriedEgg
SAS Employee

In case it will be helpful to others in the future, here is an example of using ADO to assign a new libref and select from a table within the reference using Powershell.

SasAdoDbExample.ps1

or PHP

SasAdoDbExample.php

$conn = New-Object -ComObject ADODB.Connection

#Connect to a remote server using IOM

$conn.Open('Provider=sas.IOMProvider.9.3;User ID=user;Password=pass;Data Source="";SAS Machine DNS Name=workspace.mycompany.com;SAS Port=8591;SAS Protocol=2')

#Assign a new libref using ADODB

$cmd = New-Object -ComObject ADODB.Command

$cmd.ActiveConnection = $conn

$cmd.CommandType = adCmdText

$cmd.CommandText = 'libname foo "/path/to/something"'

$cmd.Execute()

#SQL data

$recordSet = $conn.Execute("select * from foo.something")

#Collect the data from recordSet into rows array

$recordSet.MoveFirst()

$rows = @()

do

{

   $row = New-Object psobject

   for ($i=0; $i -lt $recordSet.Fields.Count; $i++)

  {

   $row | Add-Member noteproperty `

   -name $recordSet.Fields.Item($i).Name `

   -value $recordSet.Fields.Item($i).Value;

  }

   #yield

   $rows += $row

   $recordSet.MoveNext()

}

until ($recordSet.EOF -eq $true)

#create gridview of data executed in recordSet

$rows | Out-GridView

$recordSet.Close()

$conn.Close()

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 2163 views
  • 3 likes
  • 3 in conversation