Published on :

Sans titre

This code is also available in: Deutsch Español Français
Awaiting validation
Attention : This code requires administrator privileges.
1 Code Block
MACRO CONTROL
Explanation :
Conditional handling for delegating execution or preparing macro variables for transfer to the remote session via `%syslput`.
Copied!
1%IF &lmacro=q %THEN
2%DO;
3%AHGsubmitrcommand(cmd=&rcommand);
4%goto exit;
5%END;
6 
7%syslput rcommand=%bquote(&rcommand);
8%syslput lmacro=&lmacro;
9%syslput rmycmd=&rcommand;
10%syslput rformat=%str(&FORMAT);
11%syslput rdlm=%str(&dlm);
12%syslput rpiperesult=;
2 Code Block
DATA STEP Data
Explanation :
`rsubmit` block executed on the remote server. It initializes a `filename pipe` with a specific environment configuration (hardcoded paths, ksh shell), executes the command, reads the result, and returns it to the local session via `%sysrput`.
Copied!
1rsubmit;
2 
3 DATA _null_;
4 filename pip pipe "ksh -c %str(%')%bquote(. ~liu04/bin/myalias; PATH=/home/liu04/bin:/opt/sasprod:/usr/sbin:/etc:/usr/local/bin:/usr/bin:/bin:/usr/dt/bin:/usr/openwin/bin:/usr/ucb:.:/home/liu04/bin/perl;FPATH=/home/liu04/bin;)&rmycmd %str(%') " ;
5 INFILE pip truncover lrecl=32767;
6 LENGTH file $32767;
7 INPUT file 1-32767;
8 myfile=put(translate(file,"&rdlm",byte(12)),&rformat);
9 call symput("rpiperesult",trim(compbl(myfile)));
10 RUN;
11 %put lmacro=&lmacro;
12 %nrstr(%%)sysrput &lmacro=%nrbquote(&rpiperesult);
13endrsubmit;
3 Code Block
MACRO UTILITY
Explanation :
Local post-processing of the result: cleaning control characters and optional display in the log.
Copied!
1%IF %LENGTH(&&&lmacro) %THEN %let &lmacro=%sysfunc(translate(&&&lmacro,%str( ),%sysfunc(byte(12))));
2 
3 
4%IF %upcase(&PRINT)=YES %THEN %put %nrbquote(&&&lmacro);
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.