Getting SAS Macros out of X command Execution in EG

Reply
Contributor
Posts: 50

Getting SAS Macros out of X command Execution in EG

Hi all

I have some folder paths that need to come from Unix environment variables in to a SAS EG session. I tried the following:

Consider this script:

test.scr

export test="/sasem/saspath/deepak";

I execute this script via EG throught X command.

X "ksh /sasem/user/test.scr";

After the above line, I am trying to get my system variable using %sysget function.

%let path = %sysget(test);

%put &path;

LIBNAME DIRPATH "&path";

How ever the path is not getting assigned with the destined system variable.

I also tried giving this way in test.scr

export test="/sasem/saspath/deepak";

sas -stdio -log sysg.log <<EOJ

%let path = %sysget(test);

%put &path;

EOJ

Inside the EG session, I tried something like this:

X "ksh /sasem/test/test.scr";

%put &path;

LIBNAME SASPATH "&path";

The macro variable was not resolving in both the cases. I put a track with SAS support and they have told that there is no way to pass system variables from child process (process invoked by X command) to a parent process.

Is there any way to handle my scenario? Do we have any way to pass at the SAS macro variables (if not system variables) between child process to parent process?

I am using EG 4.3 and connecting it Unix server to run SAS. This is very important for us because we have some dynamic paths getting resolved via script and we need to use them inside SAS session.

Any help would be greatly appreciated. Thanks.    

Super User
Posts: 11,343

Re: Getting SAS Macros out of X command Execution in EG

What value did you get for path? If you had something other than expected posting the result might help. You only say "path is not getting assigned with the destined system variable" which leaves other values as possible.

Respected Advisor
Posts: 4,173

Re: Getting SAS Macros out of X command Execution in EG

A process started via X command runs in its own shell as a child process. From my understanding of how things work you can export an environment variable in the parent process so that the child inherits it. The parent process is protected from its child so you cannot "upload" and environment variable from a child process to its parent.

What do you actually want to achieve with this korn shell script? May be we can come up with another approach.

Ask a Question
Discussion stats
  • 2 replies
  • 374 views
  • 0 likes
  • 3 in conversation