Review your metadata profiles using SAS Enterprise Guide automation

We call it the "metadata profile", but really it's like a telephone number that connects you to your SAS environment. Just as a telephone number has component parts (country code, area code, exchange), the metadata profile contains information that allow you to "dial in" to your SAS servers. This information includes:

a host name (node name or IP address of your SAS metadata server)

a port number (the TCP/IP port that the SAS metadata server uses to accept connections)

your credentials (the user ID and password that identify you when you connect)

All of this is captured under a friendly name, which you assign when you define the profile. This is similar to the way that you would file a colleague's information in your Rolodex (still have that?) or contacts list.

When you're connected to a SAS environment in SAS Enterprise Guide, you'll see some of that profile information reflected in the status bar:

To activate a different profile or to define a new one, you can click on the Connections link in the status bar. This invokes the Connections window, showing all of your available profiles and their details.

The profile name is important, because you can make use of this name as a shortcut (similar to "speed dial") to direct SAS Enterprise Guide to a particular metadata environment automatically. To learn more, read about how to use SAS Enterprise Guide with different SAS environments.

You can also use the profile name in SAS Enterprise Guide automation scripts, as shown in this example about running SAS programs in batch.

My objective in this blog post (and I'm taking a while to get to it) is to show how to use an automation script to list the available profiles that you have defined for your installation of SAS Enterprise Guide. In this VBScript program, I use the Application.Profiles collection to obtain the details of each defined profile. To set an active profile in script, use the Application.SetActiveProfile() method. Note that if you want to run in "no profile" mode (not connected to metadata, simply using your local SAS installation), you specify "Null Provider" as the profile name. (Aside: "Null Provider" would make a great name for a rock band, or maybe for a blog.)

Here's the VBScript program:

' force declaration of variables in VB Script
Option Explicit
Dim Application
' Create a new SAS Enterprise Guide automation session
Set Application = WScript.CreateObject("SASEGObjectModel.Application.4.3")
WScript.Echo Application.Name & ", Version: " & Application.Version

' Discover the available profiles that are defined for the current user
Dim i
Dim oShell
Set oShell = CreateObject( "WScript.Shell" )
WScript.Echo "Metadata profiles available for " _
& oShell.ExpandEnvironmentStrings("%UserName%")
WScript.Echo "----------------------------------------"
For i = 0 to Application.Profiles.Count-1
WScript.Echo "Profile available: " _
& Application.Profiles.Item(i).Name _
& ", Host: " & Application.Profiles.Item(i).HostName _
& ", Port: " & Application.Profiles.Item(i).Port
Next
Application.Quit

And here's an example of the output:

C:\Examples>cscript ShowProfiles.vbs
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

Enterprise Guide, Version: 4.3.0.0
Metadata profiles available for sascrh
----------------------------------------
Profile available: Null Provider, Host: , Port:
Profile available: t2817, Host: t2817, Port: 8562
Profile available: uitsrv02, Host: uitsrv02.na.sas.com, Port: 8561
Profile available: uitsrv04, Host: uitsrv04.na.sas.com, Port: 8561