Reputation: 12691
If we run proc setinit
in SAS we can obtain the Site Name and the Site Number.
The Site Number can be easily extracted using &syssite
. Other than redirecting & parsing log output, is there a way to programmatically obtain the Site Name?
I've checked _automatic_
variables, sashelp
datasets, and proc registry
output to no avail.
Upvotes: 2
Views: 236
Reputation: 1394
I am guessing you are using SAS in UNIX environment because the path you wrote, then this document will helps.
Contents of the !SASROOT Directory - SAS® 9.4 Companion for UNIX Environments, Sixth Edition
Then the answer from @SCR comes in handy. As the document said
The !SASROOT directory contains the files required to use SAS 9.4.
and
If all available SAS products are installed on your system, the !SASROOT directory contains the files and directories that are listed in the following tables:
a file named "setinit.sas" is listed in the table in that link.
By the Way, I tried the answer from @SCR on my Windows machine, it works. Please also mind the path is "%sysget(SASROOT)\core\sasinst\setinit.sss"
.
Upvotes: 0
Reputation: 51566
Here is code to parse it from the output of PROC SETINIT
.
filename out temp;
proc printto log=out; run;
proc setinit; run;
proc printto log=log; run;
data sitename;
infile out;
input @'Site name:' @;
length sitename $200;
sitename=scan(_infile_,2,"'");
put sitename=;
output;
stop;
run;
Upvotes: 3
Reputation: 15665
This worked for me and didn't involve setting up the metadata server:
PROC IMPORT OUT= WORK.temp
DATAFILE= "D:\Program Files\SASHome\SASFoundation\9.4\core\sasinst\setinit.sss"
DBMS=DLM REPLACE;
DELIMITER='3D'x;
GETNAMES=NO;
DATAROW=1;
RUN;
proc sql noprint;
select var2 into: name
from temp
where var1 = 'SITEINFO NAME';
quit;
%put &name;
Upvotes: 3
Reputation: 12691
With pointers from Chris Blake and FriedEgg, I ended up with this solution:
data _null_;
length StoredText $2000 sitename $200;
rc=metadata_getattr("omsobj:TextStore?@Name='Setinit text'"
, "StoredText", StoredText);
storedtext=subpad(storedtext,index(storedtext,'SITEINFO NAME=')+15);
sitename=substr(storedtext,1,index(storedtext,"'")-1);
put sitename=;
run;
Upvotes: 0