BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
WaelAburezeq
Obsidian | Level 7

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? 

 

1 ACCEPTED SOLUTION

Accepted Solutions
MikeMcKiernan
SAS Employee

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;

 

View solution in original post

11 REPLIES 11
Rick_SAS
SAS Super FREQ

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. 

WaelAburezeq
Obsidian | Level 7
Thank you so much for your reply. The point is I can't rename the library,
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?
Rick_SAS
SAS Super FREQ

> 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!

WaelAburezeq
Obsidian | Level 7
Yes, you are right! I am using REST API.

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)

WaelAburezeq
Obsidian | Level 7

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

sotojcr
Obsidian | Level 7

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;
WaelAburezeq
Obsidian | Level 7
libname mycas cas caslib=Analytic_Scoring; in CAS REST API of {{sascasserver}}:8777/cas/sessions/{{sessionid}}/actions/runCode
returned this error: 
Statement is not valid or it is used out of proper order

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: 

Caslib 'Analytic_Scoring' exceeds 8 characters. Use the CASLIB= data set option for caslibs longer than 8 characters.

 

MikeMcKiernan
SAS Employee

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;

 

joeFurbee
Community Manager

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 XL, SAS Innovate 2024 Recap
Wednesday, May 15, 2024, at 10 a.m. ET | #SASBowl

WaelAburezeq
Obsidian | Level 7
hi Joe,
Yes it worked! , I marked it as a solution as well.
Thank you for the follow-up

WaelAburezeq
Obsidian | Level 7
Thumps up !
Thank you 🙂

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
  • 11 replies
  • 3356 views
  • 2 likes
  • 5 in conversation