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;
  

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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