SAS options not persistent on SAS Server - sas

I am using this
signoff;
*** REMOVED CONNECTION BLOCK;
signon;
rsubmit;
%put REUSE= %sysfunc(
getoption(REUSE)); *says no;
%put COMPRESS= %sysfunc(
getoption(REUSE)); *says no;
options compress=YES;
options reuse=YES;
endrsubmit;
And even after the option is set, whenever I reconnect it will say NO/NO for these two options.
How do I make them persistent?
Thanks

the session is ending with endrsubmit;
To persist the session:
rsubmit persist=yes;

One option for having settings persist across sessions is to use a custom autoexec file. Assuming you have access to edit your .ini file that contains the connection script, you can add -autoexec myfile.sas to that script, which would cause myfile.sas to be executed upon server connection.

Related

How to delete .filepart files in SAS Enterprise Guide

There's incomplete .filepart files in a Tests folder in SAS Enterprise Guide and I would like to delete all of them.
When I try to right click and delete, it gives me an error saying "Insufficient authorization to access /.../Tests/file.filepart"
I also tried doing this and it didn't do anything.
%macro check(file);
%if %sysfunc(fileexist(&file)) ge 1 %then %do;
%let rc=%sysfunc(filename(temp,&file));
%let rc=%sysfunc(fdelete(&temp));
%end;
%else %put The file &file does not exist;
%mend check;
%check(/.../Tests/file.filepart)
Insufficient authorization means that the user running the SAS script does not have write permission to the file you are deleting.
Did a different process / user create the .filepart files? If you have authorization to change permissions then you can use the chmod command prior to deletion to give yourself write permission (using system() or call system or x within SAS itself. If not, then this is really a system issue and you need have your admins take care of the issue for you.

Determining Server Context (Workspace Server vs Stored Process Server)

I'd like to conditionally execute code depending on whether I'm in a Workspace or Stored Process server context.
I could do this by testing the existence of an automatic STP variable, eg _metaperson, but this wouldn't be very robust.
Assuming I already have a metadata connection, how best to check my server type?
Bulletproof way would be to create a macro variable that is initialised by the autoexec or config in the required server context.
Of course this would only work if you have access and permission to modify files stored in sas configuration folder.
Hurrah - there is, in fact, an automatic variable that does just this - sysprocessmode (available since 9.4)
Extract from documentation:
SYSPROCESSMODE is a read-only automatic macro variable, which contains
the name of the current SAS session run mode or server type, such as
the following:
SAS DMS Session
SAS Batch Mode
SAS Line Mode
SAS/CONNECT Session
SAS Share Server
SAS IntrNet Server
SAS Workspace Server
SAS Pooled Workspace Server
SAS Stored Process Server
SAS OLAP Server
SAS Table Server
SAS Metadata Server
Being an automatic variable, it is of course read only:
The stored process server will preset the _PROGRAM macro variable with the program that is running. I do not know if this macro variable is read-only in the STP execution context.
But as you say, a program in the workspace context could set a _PROGRAM macro variable.
For workspace sessions look for _CLIENTAPP macro variable.
I am unaware of a function to call or immutable system option that can be examined. Try PROC OPTIONS in both contexts and see what pops out. An OBJECTSERVERPARMS value, if reported, is a list of name=value pairs. One of them would be server= and may differentiate.

assigning a metadata user via the sassrv account

I have built a test harness on the STP server, that spawns unique sessions for each test run. The problem I have now is that one of my tests requires the use of a metadata account (and my spawned sessions are running under the sassrv system account).
For info, the code snippet that spawns those sessions is below:
/**
* Execute all the backtest scripts and retain the logs
*/
options sascmd='!sascmd';
%local waitforlist;
%do x=1 %to %get_attrn(backtest_scripts,NLOBS);
signon connx&x;
%syslput LOC_BACKTEST_SCRIPTS=&LOC_BACKTEST_SCRIPTS /remote=connx&x;
%syslput TEST_RUN_NO=&TEST_RUN_NO /remote=connx&x;
%syslput TEST_ID=Test&x /remote=connx&x;
%syslput TEST_PGM=&&test&x /remote=connx&x;
%syslput LOC_TEST_RESULTS=&LOC_BACKTEST_LOGS\Test_&TEST_RUN_NO
/remote=connx&x;
%syslput LOG_LOC=&LOC_BACKTEST_LOGS\Test_&TEST_RUN_NO\&&test&x...log
/remote=connx&x;
rsubmit connx&x wait=no ;
proc printto log="&LOG_LOC"; run;
options mprint source source2;
%inc "&LOC_BACKTEST_SCRIPTS\&test_pgm..sas";
endrsubmit;
%let waitforlist=&waitforlist connx&x;
%end;
waitfor _all_ &waitforlist;
%do x=1 %to %to %get_attrn(backtest_scripts,NLOBS);
signoff connx&x;
%end;
My question - how do I now connect as a metadata user via the sassrv account? I know I could use the -metauser XXX -metapass XXX options but I'd rather not embed passwords in my script if possible..
I know (now) that we cannot set up the sassrv account as a metadata user, as it is already in use (SAS General Servers group). I also need streaming output, so cannot use the workspace server. I tried using AUTHDOMAIN on my rsubmit statement but keep getting:
ERROR: Retrieving login information based on AuthenticationDomain from
the SAS Metadata Server failed.
So, in the end, I had to connect via an options statement with metauser / metapass (encoded) credentials. However, to avoid surfacing these in the code (or in the log) we created a network share that only the system accounts could access.. Then simply %inc'd a text file containing the credentials (with option nosource2 to be sure).
Job done!

How to signon and rsubmit with user and password option, and suppress autoexec.sas in SAS

Is there a way to Not run autoexec.sas, during remote signon and rsubmit?
I have tried sascmd="sas -noautoexec" but it conflicts with the user= and password= options.
You can do as suggested by he wei
%let server = unix.penn.edu 4016; options comamid=TCP signon server nocscript sascmd='sas -noautoexec' user=aaa password=bbb; Rsubmit;
Or use another include in the program you want to recreate the macro variable user and password.

SAS 9.3 email attachment

Since upgrading to SAS 9.3, i'm only able to send emails within rsubmit, which isnt a problem... however i'm unable to attach local files, please can someone assit?
RSUBMIT;
FILENAME outmail EMAIL
SUBJECT="Daily report attached"
TO= ("xxxxx#xx.com")
ATTACH= "C:\Users\one\Desktop\Cars.xls";
DATA _NULL_;
FILE outmail;
PUT "Hello All,";
PUT ;
PUT "Please find attached the Cars report.";
PUT ;
PUT "Regards";
PUT ;
RUN;
I receive the following error message in the log:
ERROR: Error opening attachment file C:\Users\one\Desktop\Cars.xls.
ERROR: Physical file does not exist, /home/one/C:\Users\one\Desktop\Cars.xls.
Any help is much apriciated.
Thank you
Your RSUBMIT is being submitted on a server, so inside the RSUBMIT the paths are local to the server. Unless it can see your desktop (ie, via a mapped drive) it won't be able to access files on the local machine. You would have to upload them to the server first.