Your SAS programs, embedded in web apps and elsewhere

Pass libref from Stored Process to EG session

Accepted Solution Solved
Reply
Respected Advisor
Posts: 4,173
Accepted Solution

Pass libref from Stored Process to EG session


Hi all

Using SAS EG with SAS9.3 under Windows Server is there any way to run a stored process out of EG which defines a library (a libname statement) and then have this libref available in the EG session?

In real life:

I want to implement a process for SAS Forecast Studio users where I need to give the users an option to re-direct a library (libref) to another folder. This will allow the users to create forecasts on versions of the same tables with different data for "what-if" analysis (scenario planning).

In my understanding both SAS Forecast Studio and EG spawn their sessions via object spawner so I would assume if there is a solution in EG I can use the same approach for Forecast Studio. In Forecast Studio the only way to execute user written SAS code is via a stored process.

I have some ideas how I could solve the problem differently (like defining the libref in the autoexec based on some table entry or existence of a token file) so I'm not after alternative solutions.

Is it possible to somehow "connect" the 2 sessions? Any ideas greatly appreciated. - Or you just confirm my "fear" that this can't be done and I must be looking for another approach.

Thanks

Patrick


Accepted Solutions
Solution
‎04-14-2013 06:47 AM
Respected Advisor
Posts: 4,173

Re: Pass libref from Stored Process to EG session

This just to share the approach I'm now taking:

- There will be a stored process in Forecast Studio which allows to create "simulation" data sets stored in user specific locations (folders will be created by the stored process).

- There will be some logic in the autoexec which scans the user specific locations and assigns libraries if simulation data sets have been created.

- These user specific libraries will be available both in SAS EG and SAS Forecast Studio (after re-connecting to the server and so re-executing the autoexec).

...and sorry to mark my own post as the correct answer. I just want to indicate that this thread doesn't need any further contributions as I found a way of how to solve the problem.

View solution in original post


All Replies
Occasional Contributor
Posts: 7

Re: Pass libref from Stored Process to EG session

I don't have code any for this, but you could specify a libref by reading the path from a text file (that has your libref path).  Since you can read in the file from EG and from the server, you should be able to create your libref in both places.

  If you need more than that, I can look at getting you a code sample.

Respected Advisor
Posts: 4,173

Re: Pass libref from Stored Process to EG session

Hi Ben

The challenge I'm facing is that I need to define the libref as part of a stored process but that I then need this new libref available in the session used to submit this stored process.

For example using EG assume I'm having a stored process with the following code:

libname test (sashelp);

What I would like to do is to execute this stored process via EG and then have the libref "test" available in my EG session.

Thanks

Patrick

Occasional Contributor
Posts: 7

Re: Pass libref from Stored Process to EG session

I believe this approach will work (this is for Unix but should work similarly for Windows).

  1. Store the path of your desired libref in a file that is accessible from EG and from your SAS Server.
    1. For example, myilb.txt contains "/folder/desired path/"
  2. Read in the file contents using a data step (infile)
  3. Store the results of the file in a macro variable
    1. For example, call symput('libvar',file_txt);
  4. Reference the library using the macro variable
    1. &libvar..some_dataset

Hopefully this helps.

Respected Advisor
Posts: 4,173

Re: Pass libref from Stored Process to EG session

Hi Ben

Sorry but I believe you're missing the point here. A SAS Stored Process runs in it's own session so whatever I'm doing there doesn't alter the parent session from where I kick off the stored process - but that's what I'm after: A way to define a libref in a stored process which then is available within the parent session (so an EG session for example). I can't run any additional code in the parent session as Forecast Studio only allows me to run custom code as stored process (except for start-up/shut-down code - but that's not in the place in the process where I need the libname executed).

So what I'm after is to give Forecast Studio users a possibility to point a libref to another folder (within Forecast Studio a prompt where they can choose the folder and then executing a libname using this path).

Thanks

Patrick

Solution
‎04-14-2013 06:47 AM
Respected Advisor
Posts: 4,173

Re: Pass libref from Stored Process to EG session

This just to share the approach I'm now taking:

- There will be a stored process in Forecast Studio which allows to create "simulation" data sets stored in user specific locations (folders will be created by the stored process).

- There will be some logic in the autoexec which scans the user specific locations and assigns libraries if simulation data sets have been created.

- These user specific libraries will be available both in SAS EG and SAS Forecast Studio (after re-connecting to the server and so re-executing the autoexec).

...and sorry to mark my own post as the correct answer. I just want to indicate that this thread doesn't need any further contributions as I found a way of how to solve the problem.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 366 views
  • 0 likes
  • 2 in conversation