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


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

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

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

5 REPLIES 5
BenB
Calcite | Level 5

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.

Patrick
Opal | Level 21

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

BenB
Calcite | Level 5

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.

Patrick
Opal | Level 21

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

Patrick
Opal | Level 21

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.

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
  • 1062 views
  • 0 likes
  • 2 in conversation