BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DaveShea
Lapis Lazuli | Level 10

Hi,

I am trying to come up to speed with SAS Viya and have been looking at some of the great SAS videos that are available at: https://video.sas.com/category/videos/an-introduction-to-sas-viya-programming-for-sas-9-programmers

 

I'm not yet working on a SAS Viya site, but want to get the concepts clear in my head and I've boxed myself into a corner on a little point that I would like some clarification on.

 

In one video (Using the DATA Step in SAS® Viya™) the demonstration shows the following code:

 

cas mysess sessopts=(caslib=casuser);
libname mycase cas;

proc casutil;
load data=sashelp.cars replace;
run;

 

and in another video (Understanding Caslibs and Loading Data in SAS® Viya™)  doing more or less the same thing, the demonstration shows the following, slightly different code:

cas mysess sessopts=(caslib=casuser);
libname mycase cas caslib=casuser;

proc casutil;
load data=sashelp.cars replace;
run;

The difference is that in the second video the assignment of the CASLIB occurs in both the SESSOPTS statement as well as the LIBNAME statement. In the first video however, the assignment only occurs in the SESSOPTS statement.

 

I have assumed from the first video that using the SESSOPTS statement to assign the CASLIB means that the immediately following LIBNAME statement does not have to explicitly reference the CASLIB=CASUSER relationship because that has been set as the default for the whole cas session. Is this correct ? If so, is the LIBNAME statement in the second video just re-iterating the relationship ? No mention was made in either video about the CASLIB reference being optional in the LIBNAME statement if it had been referenced as part of SESSOPTS and similarly, no mention was made of it being mandatory to use the SESSOPTS statement.

 

This isn't a moan, it's just I have been a bit confused. If anyone can give a concise answer to my less-than concise question, I would really appreciate it.

 

Cheers,

 

Downunder Dave
Wellington

1 ACCEPTED SOLUTION

Accepted Solutions
Edoedoedo
Pyrite | Level 9

Hi, as far as I know (I'm a sas 9.4 expert but I'm new in Viya) what happens should be this:

 

- when you initialize a cas session you can specify a caslib (sasuser in this case), which becomes the "active" caslib

- there exists only an "active" caslib at a time

- if you specify a statement which require a caslib in some option, you may omit it and the "active" caslib will be used

- otherwise, you may specify a different caslib (not the "active")

- the cas engine in libname requires a caslib to attach to; in the first case, it will use the "active" caslib (which is sasuser) by default; in the second case you explicitly specify that the libname mycase is attached to casuser.

 

Since casuser is indeed the "active" caslib, the two codes are equivalent (and in the second one "caslib=casuser" in the libname statement is useless).

 

BUT, this is what I have understand so far, I'm not sure I got it right!

 

Regards

View solution in original post

4 REPLIES 4
Edoedoedo
Pyrite | Level 9

Hi, as far as I know (I'm a sas 9.4 expert but I'm new in Viya) what happens should be this:

 

- when you initialize a cas session you can specify a caslib (sasuser in this case), which becomes the "active" caslib

- there exists only an "active" caslib at a time

- if you specify a statement which require a caslib in some option, you may omit it and the "active" caslib will be used

- otherwise, you may specify a different caslib (not the "active")

- the cas engine in libname requires a caslib to attach to; in the first case, it will use the "active" caslib (which is sasuser) by default; in the second case you explicitly specify that the libname mycase is attached to casuser.

 

Since casuser is indeed the "active" caslib, the two codes are equivalent (and in the second one "caslib=casuser" in the libname statement is useless).

 

BUT, this is what I have understand so far, I'm not sure I got it right!

 

Regards

DaveShea
Lapis Lazuli | Level 10

Hi EduxEdux,

 

Thanks for your reply. I think that you are correct in that, in the second code snippet, either of the two references to CASLIB=CASUSER are superfluous:

cas mysess sessopts=(caslib=casuser);
libname mycase cas caslib=casuser;

Whilst it probably does no harm, I did find it a bit confusing as to why the CASLIB was being defined twice. My personal preference would be to explicitly reference the CASLIB=CASUSER on the LIBNAME statement, nice and bold and obvious to the reader.

 

My view of the LIBNAME statement has always been that it is the place where the user declares the connection between the Libref and the data source, irrespective of whether that data source is a SAS data library, an Excel workbook, an ORACLE database or a SAS Viya CASLIB. Consequently I think that it would be logical to keep using the same methodology in SAS Viya too,

 

Ho hum, new things to learn. I think I need to find lots more examples of using SAS code to SAS Viya to help drum this new stuff in Smiley Wink

 

Thanks again.

 

Downunder Dave

AmitGoel
Calcite | Level 5

Hi,

 

I think its better to explicitly specify CASLIB option in LIBNAME statement to be sure which caslib our libref is referring to.

 

Please see below link which specifies that "Binding the CAS engine libref with the active caslib prevents the CAS engine libref from switching to a subsequently added caslib."

 

http://documentation.sas.com/?cdcId=pgmcdc&cdcVersion=8.11&docsetId=pgmdiff&docsetTarget=n1hjajagui3...

 

Cheers,

Amit

DaveShea
Lapis Lazuli | Level 10

Hi Amit,

 

Thanks for your reply and the reference to the documentation. I have flagged EduxEdux's reply as the solution although I would like to do the same for yours.

 

I agree with your assertion that it is better to explicitly specify the CASLIB=xxxx option in LIBNAME statement so that it is obvious to the user which caslib our libref is referring to.

 

I guess that we all have a long and interesting path to tread with SAS Viya, I'm looking forward to the journey Smiley Happy

 

Cheers,

 

Downunder Dave

Wellington

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
  • 4 replies
  • 2048 views
  • 0 likes
  • 3 in conversation