Hi All,
I have a question regarding the use of a libref to a CAS library. In the code example below, I have a CAS library with a name that's longer than 8 characters. As a result, the library doesn't show up in SAS Studio when I assign libraries. To actively keep track of the available data while working in SAS Studio, I use a libname statement to bind a shorter libref to the CAS library. The shorter libref works fine when I use it in the data step. However, PROC CASUTIL somehow does not recognize the shorter libref. Instead, I get "ERROR: The caslib 'INFO' does not exist.".
I would appreciate it if anyone could give me insight into why the shorter libref does not seem to work in PROC CASUTIL.
libname info cas caslib = infographics;
data info.test1;
input_data = "02-2020"; output;
run;
data info.test2;
set info.test1;
format output_date monyy7.;
output_date = input(input_date, anydtdte7.);
run;
proc casutil;
save casdata = "test2" incaslib = "info"
casout = "test2" outcaslib = "info" replace;
droptable casdata = "test2" incaslib = "info" quiet;
load casdata = "test2.sashdat" incaslib = "info"
casout = "test2" outcaslib = "info" promote;
quit;
I work on SAS Viya version 3.5 and SAS Studio version 5.2.
All of the PROC CASUTIL parameters referencing caslibs need the actual caslib name - not the libref you assigned to the caslib. PROC CASUTIL generated CAS action that run in CAS, so the program won't have access to any of the resources on the Compute Server when it executes. Using the actual caslib name for INCASLIB and OUTCASLIB should fix the problem. Try something like this:
libname info cas caslib = infographics;
data info.test1;
input_data = "02-2020"; output;
run;
data info.test2;
set info.test1;
format output_date monyy7.;
output_date = input(input_date, anydtdte7.);
run;
proc casutil;
save casdata = "test2" incaslib = "infographics"
casout = "test2" outcaslib = "infographics" replace;
droptable casdata = "test2" incaslib = "infographics" quiet;
load casdata = "test2.sashdat" incaslib = "infographics"
casout = "test2" outcaslib = "infographics" promote;
quit;
May the SAS be with you!
Mark
Is there anyway to discover the CAS name for the libref that is created using the CAS engine?
For example what does the PATHNAME() function return for the INFO libref in the example program?
Or what information is available in the DICTIONARY.LIBNAMES or SASHELP.VLIBNAM?
%let remote=%sysfunc(pathname(info));
proc casutil;
save casdata = "test2" incaslib = "&remote"
...
Not to my knowledge. This code:
cas mySession;
libname x cas caslib="casuser";
%put NOTE: %qsysfunc(pathname(x));
proc cas;
session.sessionID;
quit;
Produces this output in the log:
0 %put NOTE: %qsysfunc(pathname(x)); NOTE: f67a5830-2590-a14b-b399-958a8299e619 81 proc cas; 82 session.sessionID; 83 quit; NOTE: Active Session now MYSESSION. {MYSESSION:Sun Jun 13 14:28:33 2021=f67a5830-2590-a14b-b399-958a8299e619} NOTE: PROCEDURE CAS used (Total process time):
So you can see that PATHNAME is returning the UUID of the CAS session, not the caslib. Right-clicking on the library in SAS Studio and choosing Properties will show the same results.
Unless there are caslib librefs in your SAS session that were automatically assigned by the SAS Administrator, you would have to have assigned them in your code. Librefs assigned with the CASLIB _ALL_ ASSIGN; statement will automatically match the caslib name. And for librefs individually assigned with LIBNAME statements, the association should be self-evident in the code...
May the SAS be with you!
Mark
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: