I would like to retrieve the path of a caslib and store it as a SAS macro variable.
I have been able to use the table.caslibinfo and print the result:
proc cas;
table.caslibinfo result=sss/caslib="Mycaslib" ;
describe sss;
print sss;
run;
Would I would like to do is somehow parse the result so that I just end up with the path (physical datasource path of the caslib) and store that in a SAS macro variable.
For comparision If this was a SAS library (MYLIB )I would do something like this:
%let my_mvar= %sysfunc(pathname(MYLIB));
Does anybody have any ideas?
thanks
I have found the answer thanks to this link
https://blogs.sas.com/content/sgf/2017/11/28/interacting-with-the-results-of-proc-cas/
need to use the saveresult statement to create a SAS dataset from the result . i.e.
proc cas;
table.caslibinfo result=sss/caslib="MyCaslib" ;
describe sss;
print sss;
saveresult sss dataout=work.xdata;
run;
proc sql;
select path into:myvar
from work.xdata;
quit;
%put myvar = &myvar;
A CAS library points to a Viya App server in-memory location so there is no such thing as a physical folder path.
Have look at how a CAS LIBNAME is defined: https://documentation.sas.com/?docsetId=casref&docsetTarget=p088ys3kvgve4en12e8ug6jkkjxy.htm&docsetV...
Edit: Ah, but now I see you are referring to the source path of the CASLIB which you can list with the CASLIB statement:
caslib MyCASLib list;
I'm thinking it may be possible to redirect this output then read it into macro variables. I don't have Viya to test this though.
I have found the answer thanks to this link
https://blogs.sas.com/content/sgf/2017/11/28/interacting-with-the-results-of-proc-cas/
need to use the saveresult statement to create a SAS dataset from the result . i.e.
proc cas;
table.caslibinfo result=sss/caslib="MyCaslib" ;
describe sss;
print sss;
saveresult sss dataout=work.xdata;
run;
proc sql;
select path into:myvar
from work.xdata;
quit;
%put myvar = &myvar;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.