- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
and I can't just replace it since it contains lot of previous work. How can
I use data step in run.code and in the same time create a reference library
the same way I did in SAS studio?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
> 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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to dynamically add rows to target table then do the scoring
(model.run). The cas library reference that you mentioned is a solution- as
first highlighted in my email- however this requires keep creating temp
libraries and deleting them in every session.
Do you think that PROC CASUTIL willl work instead of data step in .run_code
action? I will give it a try, but I am afraid that we will fave the same
libname issue (exceeding 8 characters)
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 L, PROC HTTP
Wednesday, February 19, 2024, at 10:00 a.m. ET | #SASBowl
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes it worked! , I marked it as a solution as well.
Thank you for the follow-up
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you 🙂