BookmarkSubscribeRSS Feed
smm662002
Quartz | Level 8

Hello,

 

SAS VIYA:   3.5

SAS Studio: 5.2 

 

Has anyone managed to write to a non standard caslib in a data step? 

I have tried the following but it returns error.

 

data "My CAS".table;

set casuser.table1;

run;

 

I am aware that it is possible to do it in a proc fedsql.

 

proc fedsql sessref=test;

create table "My CAS".table as 

select * from 

casuser.table1;

quit;

 

Thank you,

smm662002

 

 

8 REPLIES 8
Rick_SAS
SAS Super FREQ

How did the "My CAS" caslib get defined? Does it show up if you list all caslibs by using

caslib _all_ list;   /* display all caslibs to log */

I have never done it, but the SAS documentation states: "You can use name literals (n-literals) in caslib names. However, the CAS LIBNAME engine statement does not support caslib names with name literals in them."

To me, this suggests that you might try

data "My CAS"n.table;
...
run;

because "My CAS"n is the standard way to specify an n-literal.  Let us know if that works or not.

smm662002
Quartz | Level 8
Hi,

Thank you for your reply.
The caslib shows up in the list when using calib _all_ list but when trying to use data "My CAS"n.table;
...
run;
it returns an error saying that the Libref exceeds 8 characters (because the libname I am using has more than 8 characters)

Regards,
smm662002

Rick_SAS
SAS Super FREQ

1. How did the "My CAS" caslib get defined? 

2. If you run the following code, does the log verify that the value of the VALIDVARNAME option is 'ANY'?
proc options option=validvarname value;
run;
For example, the output might look like this:

Option Value Information For SAS Option VALIDVARNAME
Value: ANY
Scope: Compute Server

smm662002
Quartz | Level 8
Hi,

The CASLIB was defined by the SAS admin so not sure exactly how they have done it.
The log verify that the value of the VALIDVARNAME option is 'ANY' but this is on the Compute Server while the code would run on CAS server.

Thank you,
smm662002
Rick_SAS
SAS Super FREQ

> but this is on the Compute Server while the code would run on CAS server.

Not quite true. All PROCs and DATA steps are parsed on the compute server, and so the librefs and caslibs have to be defined there. Your code executes on the client, but if all data are in CAS tables, then it results in a call to the dataStep.runCode action, which will actually perform the data processing.

 

I don't know how to resolve your problem by using the DATA step. However, if your goal is to create a new table, you could use the LOAD statement in PROC CASUTIL or directly call the table.loadtable action by using PROC CAS.

 

I can't test this code since I don't know how to define a "My CAS" caslib, but does the following code show your data table?

/* UNTESTED code */
proc casutil;
list tables incaslib="My CAS";  /* does this work? */
quit;

If so, try

/* if so, try to transfer it to caseuser.table1 */
proc casutil;
load casdata='table' incaslib="My CAS"
     casout='table1' outcaslib='casuser';
list tables incaslib='casuser'; 
run;

 

smm662002
Quartz | Level 8
Hi,

proc casutil;
list tables incaslib="My CAS"; /* does this work? */
quit;

works ok.

The goal was to find if I can use nonstandard caslibs in data steps. Otherwise I can always use fedsql if needed.

Thank you for your help.

Regards,
smm662002
Rick_SAS
SAS Super FREQ

I am out of ideas. Perhaps @alexal or someone else can assist.

alexal
SAS Employee

@smm662002 ,

Please show the library definition and exact error you are receiving when using data step.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 8 replies
  • 708 views
  • 2 likes
  • 3 in conversation