BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
34reqrwe
Quartz | Level 8

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

1 ACCEPTED SOLUTION

Accepted Solutions
34reqrwe
Quartz | Level 8

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;
  

View solution in original post

3 REPLIES 3
SASKiwi
PROC Star

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.

34reqrwe
Quartz | Level 8
thanks, yes its confusing coming to Viya from SAS as there are similarities but also differences. I want to do exactly what you describe and redirect the output but haven't been able to work out how .
34reqrwe
Quartz | Level 8

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;
  

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2383 views
  • 1 like
  • 2 in conversation