Hi fellows,
I am facing an error due to my libname (that is used for scoring purposes) exceed 8 characters. And thus, I can't append any table to the targeted one. The error is as follow :
curl -X POST \ https://casserver/cas/sessions/{{sessionid}}/actions/runCode \ -H 'Authorization: Bearer ey...' \ -H 'Content-Type: application/json' \ -d '{"code": "data Analytic_Scoring.LAB_RESULTS_CLASSIFICATION(append=force) ; set Analytic_Scoring.data201902;run;"}'
"ERROR: Caslib 'Analytic_Scoring' exceeds 8 characters. Use the CASLIB= data set option for caslibs longer than 8 characters"
The same happens in SAS Studio. However, I was able to create a smaller reference and that worked.
libname mycas cas caslib=Analytic_Scoring;
Data Mycas.table_name etc
And then using mycas reference in SAS Studio. BUT, the same sentence is not working in the following script:
curl -X POST \ https://casserver/cas/sessions/{{sessionid}}/actions/runCode \ -H 'Authorization: Bearer ey...' \ -H 'Content-Type: application/json' \ -d '{"code": "libname mycas cas caslib=Analytic_Scoring;"}'
I get "ERROR: Statement is not valid or it is used out of proper order" I don't want to keep creating temporally cas lib as well.
Going back to the first error and this documentation , what does "Caslib= data set option for caslib longer than 8 characters"
refer to? how can I apply it?
I tried this with PROC CAS and the dataStep.runCode action, so it should be similar to using the runCode action with REST.
Instead of using a two-level name, use the table name alone and specify the caslib name in a data set option.
data LAB_RESULTS_CLASSIFICATION(append=force caslib=Analytic_Scoring) ; set data201902(caslib=Analytic_Scoring);run;
I _predict_ that should work. That prediction is based on what I managed to get working for myself.
cas casauto; caslib averylongcaslibname datasource=(srctype="path") path="/tmp"; /* The active caslib is set to averylong... */ proc casutil; load data=sashelp.cars; run; proc cas; datastep.runcode / code=" data longishtablename(append=yes caslib=averylongcaslibname); set cars(caslib=averylongcaslibname); run;"; run;
I don't have any experience using long CAS librefs, but I looked at the doc and here's what I think is happening:
1. The LIBNAME statement is a global statement. It is not a DATA step statement, which is why you get an error when you try to run it in the runCode action.
2. As far as I can tell, the runCode action does not support CAS librefs that exceed 8 characters, which is what the first part of the error message is telling you. However, the second part of the error message is meant for the DATA step, which supports the CASLIB= data set option and which you can use to specify longer CAS librefs.
3. The simplest (and maybe) only way to use the action is to use an 8-character libref.
4. If you are submitting your code from a SAS session, you could use the longer libref, but you would have to use the DATA step syntax, not the runCode action.
> The point is I can't rename the library
1. You can define a new libref that points to the same CAS library and session.
2. I don't know what you are trying to accomplish, but your example is transferring a SAS data set into a CAS table. If that is your goal, you do not need to use the DATA step (or runCode action). You can use PROC CASUTIL (UNTESTED code):
proc casutil ;
load data=Analytic_Scoring.LAB_RESULTS_CLASSIFICATION outcaslib="Analytic_Scoring" casout="data201902" append ;
run ;
You can read more about PROC CASUTIL and appending data.
It's still not clear to me how you are submitting actions. Several of your examples appear to use a REST api, so I'll call @joeFurbee to see if he has additional suggestions. Good luck!
when I ran the PROC CASUTIL, I got the followings:
Libref 'Analytic_Scoring' exceeds 8 characters
Which seems to be very similar to the Data Step error
follow the example in : https://documentation.sas.com/?docsetId=casref&docsetTarget=n0lgusu0v43zxwn1kc5m6cvtnzey.htm&docsetV...
try by example:
caslib Analytic_Scoring path="<your_path>"
datasource=(srctype="<source_type>");
libname mycas cas caslib=Analytic_Scoring;
data mycas.LAB_RESULTS_CLASSIFICATION(append=force);
set Analytic_Scoring.data201902;
run;
that's the main point behind this post, however whenever I use the rest of your code (either data step or Proc CASUTIL) in Analytic_Scoring.TABLE_NAME, the error says:
I tried this with PROC CAS and the dataStep.runCode action, so it should be similar to using the runCode action with REST.
Instead of using a two-level name, use the table name alone and specify the caslib name in a data set option.
data LAB_RESULTS_CLASSIFICATION(append=force caslib=Analytic_Scoring) ; set data201902(caslib=Analytic_Scoring);run;
I _predict_ that should work. That prediction is based on what I managed to get working for myself.
cas casauto; caslib averylongcaslibname datasource=(srctype="path") path="/tmp"; /* The active caslib is set to averylong... */ proc casutil; load data=sashelp.cars; run; proc cas; datastep.runcode / code=" data longishtablename(append=yes caslib=averylongcaslibname); set cars(caslib=averylongcaslibname); run;"; run;
Hi @WaelAburezeq,
Have you been able to attempt the recommendation from @MikeMcKiernan? Can we accept that as the solution? Thanks!
Join us for SAS Community Trivia
SAS Bowl XLIII, The New SAS Developer Portal
Wednesday, August 14, 2024, at 10 a.m. ET | #SASBowl
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.