BookmarkSubscribeRSS Feed
kenwdcao
Calcite | Level 5

Dear community,

 

We recently upgrade our SAS environment from PC SAS to SAS Studio. After some research, we decided to use SAS Integration Technologies to build our batch submit tool (remote submit programs from client machines/VMs to SAS server). The prototype works on our currently VMs (which has PC SAS installation). We need to test the tool on the environment that has no BASE SAS installation. Based on the documentation, I was under the impression that it should work as long as SAS Integration Technologies client for windows is installed. However, after testing I couldn't get the tool running on the test machine. To be accurate, with SAS Integration Technologies installed, the tool can run but failed in creating workspace server. Below is the (PowerShell) code that fails:

 

$objFactory = New-Object -ComObject SASObjectManager.ObjectFactoryMulti2
$objServerDef = New-Object -ComObject SASObjectManager.ServerDef
$objServerDef.MachineDNSName = "<SAS-Workspace-Server-Address>"
$objServerDef.Port = 8591 
$objServerDef.Protocol = 2
$objServerDef.ClassIdentifier = "440196d4-90f0-11d0-9f41-00a024bb830c"

try {
    # create and connect to the SAS session 
    $workspaceserver = $objFactory.CreateObjectByServer(
        "SASApp", # server name
        $true, 
        $objServerDef, # built server definition
        "<User-Name>", # user ID
        "<Password>"    # password
    )
    $workspaceserver.LanguageService.Submit("option set=a=""Hello World"";") 
    $sasrtn = "" 
    $rc = $WorkspaceServer.Utilities.HostSystem.GetEnv("a", [ref] $sasrtn) 
    Write-Host $sasrtn
    $workspaceserver.Close()
}
catch [system.exception] {
    Write-Host "Could not connect to SAS session: " $_.Exception.Message
}

 

The error I got is 

Could not connect to SAS session:  <connectionAttempts>
        <connectionAttempt>
                <description>Unspecified error</description>
                <status>0x80004005</status>
                <saslogin>XXXXXXXXXXXXXX</saslogin>
                <sasmachinednsname>XXXXXXXXXXXXXX</sasmachinednsname>
                <sasport>8591</sasport>
                <sasclassid>440196d4-90f0-11d0-9f41-00a024bb830c</sasclassid>
                <sasprogid>SAS.Workspace.1.0</sasprogid>
                <threadid>4704</threadid>
                <name>SASApp</name>
        </connectionAttempt>
</connectionAttempts>

The same code can run sucessfully on our current VM where BASE SAS is installed. I can't tell if this is due to some settings on the test machine that is irrelevant to SAS, or is it due to the fact that SAS Integration Technologies alone cannot support the funtion of this code.

 

Does anyone have any experience on this topic? Thanks in advance!

 

2 REPLIES 2
AllanBowe
Barite | Level 11

This doesn't answer your question but it could be something to consider given your use case (migration of PC SAS to work on a remote machine)

My team have built an open source REST API for Base SAS, the source is here:  https://github.com/sasjs/server

Using this you can batch submit SAS programs from any client on any network connected (non-SAS) machine, including the SASjs CLI (https://cli.sasjs.io), and fetch both the log and print output.

Docs are here:  https://server.sasjs.io

If you were to use the SASjs CLI to set up your batch process, the benefit would be a very smooth migration to Viya at a later date (the functionalities work the same regardless of server type)


/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
AlanC
Barite | Level 11

Apologies, I don't have SAS so working from memory.

 

I thought that when you installed SAS IT, it would install a small client program for testing. It is in your Windows Menu under SAS Integration Technologies. Use that to get your client working before putting it into PowerShell. 

 

Here is some C# code I have used with references to InterOp.ADODB, SAS, SASObjectManager, SASWorkspaceManager). I have lots of code around this area so ping if needed and I will drop on github. When given a choice, I prefer C# to PowerShell. Both are good but C# is easier to read and maintain, IMO:

 

        private Workspace CreateWorkspace()
        {
            Workspace sasWorkspace;
            try
            {
                var objFactory = new ObjectFactoryClass();
                var serverDef = new ServerDefClass();

                // ************************************************
                // Configure the SAS server information.
                // ************************************************

                serverDef.BridgeEncryptionAlgorithm = "SASProprietary";
                serverDef.BridgeEncryptionLevel = EncryptionLevels.EncryptUserAndPassword;
                serverDef.MachineDNSName = DnsName;
                serverDef.Port = Port;
                serverDef.Protocol = Protocols.ProtocolBridge;

                // ************************************************
                // Create the connection.
                // ************************************************

                sasWorkspace =
                    (Workspace) objFactory.CreateObjectByServer("BridgeConnection", true, serverDef, UserId, Password);
            }
            catch (Exception ex)
            {
                util.HandleError(MethodBase.GetCurrentMethod().Name, ex);
                return null;
            }
            return sasWorkspace;
        }
https://github.com/savian-net

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 1070 views
  • 0 likes
  • 3 in conversation