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

When developing an Add-in for enterprise guide, and executing a stored process using

obWs.LanguageService.StoredProcessService.Execute("abc.sas","")

I find that, if the work library path of obWs is /sas/temp/abcde, then all datasets created by the stored process are stored in a sub-directory under the work path, such as /sas/temp/abcde/a12345/.

So I can't visit them using OleDbConnection got from obWs because the work library paths of obWs and StoredProcessService are different.

Any ideas? Thanks!

public SAS.Shared.AddIns.ShowResult Show(System.Windows.Forms.IWin32Window Owner) {

    SAS.Tasks.Toolkit.SasServer obServer;

    SAS.IWorkspace obWs = null;

    string strServer = consumer.AssignedServer;

    consumer.Workspace(strServer);

    try {

        obWs = consumer.Workspace(strServer) as SAS.Workspace;

        obServer = new SAS.Tasks.Toolkit.SasServer(strServer);

    } catch {

        return SAS.Shared.AddIns.ShowResult.Canceled;

    }

.....................

}

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

Hello,

Is there a reason that you want to execute the program as a Stored Process instead of simply running the program "as is" in your SAS Workspace?  You can effectively run the program by using:

SAS.Tasks.Toolkit.SasSubmitter submitter = new SasSubmitter(sasServer);

string outLog;

bool success = submitter.SubmitSasProgramAndWait("%include '/sas/myprogram/abc.sas';", out outLog);


When you run a stored process, the SAS session that executes the program is different than the SAS Workspace that SAS Enterprise Guide is connected to.  You cannot easily share the content of the WORK library, since it's actually a different SAS executive that's running.


The SAS Macro Variable Viewer task (GitHub link) shows an example of how to run a program interactively.


And LanguageService.StoredProcessService is an older, legacy method for stored processes.  When we talk about SAS Stored Processes in the SAS 9.x (9.1 and later) environment, there is another API dedicated to managing/running stored processes -- all tied to SAS Metadata.  You can find the documentation and examples for that API within StoredProcessService.chm, found in your local Integration Technologies installation folder (ex: C:\Program Files\SAS\SharedFiles(32)\Integration Technologies).


Chris

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

View solution in original post

4 REPLIES 4
ChrisHemedinger
Community Manager

Hello,

Is there a reason that you want to execute the program as a Stored Process instead of simply running the program "as is" in your SAS Workspace?  You can effectively run the program by using:

SAS.Tasks.Toolkit.SasSubmitter submitter = new SasSubmitter(sasServer);

string outLog;

bool success = submitter.SubmitSasProgramAndWait("%include '/sas/myprogram/abc.sas';", out outLog);


When you run a stored process, the SAS session that executes the program is different than the SAS Workspace that SAS Enterprise Guide is connected to.  You cannot easily share the content of the WORK library, since it's actually a different SAS executive that's running.


The SAS Macro Variable Viewer task (GitHub link) shows an example of how to run a program interactively.


And LanguageService.StoredProcessService is an older, legacy method for stored processes.  When we talk about SAS Stored Processes in the SAS 9.x (9.1 and later) environment, there is another API dedicated to managing/running stored processes -- all tied to SAS Metadata.  You can find the documentation and examples for that API within StoredProcessService.chm, found in your local Integration Technologies installation folder (ex: C:\Program Files\SAS\SharedFiles(32)\Integration Technologies).


Chris

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
qkaiwei
Calcite | Level 5

:smileyblush:

You know, as a programmer outside SAS, the possible way of developping EG Add-In is to guess and try, more examples and papers need to be brought into the public.

Anyway, thank you!

ChrisHemedinger
Community Manager

No need to guess and try!  There is a comprehensive book available on this topic:

Custom Tasks for SAS Enterprise Guide using Microsoft .NET

by Chris Hemedinger


Visit http://go.sas.com/customtasksapi to learn more and see lots of examples.


And SubmitSASProgramComplete is the event that is raised for asynchronous processing.  The book describes this class and provides examples.


Chris


SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
qkaiwei
Calcite | Level 5

:smileylaugh:

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2011 views
  • 3 likes
  • 2 in conversation