DATA Step, Macro, Functions and more

Exporting The variable value from SAS to UNIX

Reply
Occasional Contributor Uli
Occasional Contributor
Posts: 8

Exporting The variable value from SAS to UNIX

Dear All,

Can you please help me out of this issue.

I hacve created sample.sas program, please find the program below.
sample.sas program :

data a;
input a $5.;
datalines;
hello
howru
;

proc sql;
select a into :id separated by ',' from a ;
quit;


data _null_;
call system('export var="&id."');
run;

I have created samp.sh program , here i am executing the sample.sas program and print the output from SAS program in UNIX environment. I am not getting the result.

*shell Script:
samp.sh

#!/usr/bin/ksh

sas sample.sas

echo $var




Could you please help me out about the above issue. I have used X command as well.

Thanks In Advance.

Best Regards
Valued Guide
Posts: 2,174

Re: Exporting The variable value from SAS to UNIX

might try replacing
call system('export var="&id."');
with
call system("export var=""&id.""");
If the shell script command "export" supports single quotes, then use
call system("export var='&id.'");
Super User
Posts: 9,676

Re: Exporting The variable value from SAS to UNIX

Maybe You can code like this:
[pre]


data a;
input a $5.;
datalines;
hello
howru
;
run;
data _null_;
set a end=last;
file '/usr/bin/ksh/samp.sh';
length id $ 500;
retain id;
id=catx(' ',a);
if last then do;
envir_var='export var='||id;
put envir_var;
end;
run;

[/pre]


Ksharp
SAS Employee
Posts: 25

Re: Exporting The variable value from SAS to UNIX

SAS Employee
Posts: 2

Re: Exporting The variable value from SAS to UNIX

The reason why this is so difficult is because environment variables are inherited by the child process but the parent process is unaffected by the child process.
Ask a Question
Discussion stats
  • 4 replies
  • 681 views
  • 0 likes
  • 5 in conversation