BookmarkSubscribeRSS Feed
luca87
Obsidian | Level 7

Hi, 
I have this code that works:

 

%let caslib = AAAA;
%let libname=SASHELP;
%let table=CARS;

  cas mysess sessopts=(caslib=&caslib.);
  caslib _ALL_ assign;

/* load */
proc casutil;
	load data=&libname..&table.
	outcaslib="&caslib." casout="&table." REPLACE;
run;

proc cas;
	loadactionset / actionSet="dataDiscovery";
run;
	dataDiscovery.profile result=r / table={name="&table."},
	casOut={name="Profilazione", replace=true};
run;

 

but if i use this it gives me an error:

 

%let caslib = AAAA;
%let libname=SASHELP;
%let table=CARS;

  cas;
  libname &caslib. cas caslib=&caslib.;

/* load */
proc casutil;
	load data=&libname..&table.
	outcaslib="&caslib." casout="&table." REPLACE;
run;

proc cas;
	loadactionset / actionSet="dataDiscovery";
run;
	dataDiscovery.profile result=r / table={name="&table."},
	casOut={name="Profilazione", replace=true};
run;

 

 

I just changed the bold part. Instead of allocating all CAS I allocate only one.


The error are:

ERROR: Could not connect to the Hadoop cluster.
ERROR: Table 'CARS' could not be loaded.
ERROR: Failure opening table 'CARS': A table could not be loaded.
ERROR: The action stopped due to errors.

Thanks

Luca

 

1 REPLY 1
Panagiotis
SAS Employee

I think it's because you are not specifying the caslib in the dataDiscovery.profile action.

 

In CAS, you have what's called an active caslib. The active caslib is like your current working directory. If you do not specify a caslib, CAS will use the active caslib. By default, the Casuser caslib is typically the active caslib. You can check with this code:

proc cas;
    sessionProp.getSessOpt / name = 'caslib';
quit;
/* results */ {caslib=CASUSER(user-name)}

 

 

In your working code you changed the active caslib in the CAS statement to the AAAA caslib. Now if you specify a CAS table without specifying where the CAS table is, it'll use AAAA by default.

cas mysess sessopts=(caslib=&caslib.);

 

Then you load the sashelp.cars SAS data set into memory in the AAAA caslib. Now this data set was loaded to the AAAA caslib (whatever data source that connects to. Could be a database, path, cloud, etc.). In the CASUTIL code you specified the outcaslib parameter, indicating which caslib you want to load this table to. If you didn't specify the outcaslib parameter, it would use the active caslib.

proc casutil;
	load data=&libname..&table.
	outcaslib="&caslib." casout="&table." REPLACE;
run;

 

In your dataDiscover.profile action you don't specify where the CAS table you want is. So SAS will use the active caslib by default. In your working code the active caslib is AAAA since you set it in your CAS statement. In the code that's erroring out my guess is the active caslib is Casuser, and the CARS table doesn't exist in Casuser.

 

	dataDiscovery.profile result=r / table={name="&table."},   /* <--where should I look for this table??? SAS will look in the active caslib */
	casOut={name="Profilazione", replace=true};                /* <--where should I create this table??? SAS will use the active caslib */
run;

 

 

I recommend always specifying the caslib and not relying on the active caslib, even though it's not always required. It's very easy to change the active caslib accidently, and this could cause issues like this. Being explicit avoids these issues and honestly makes your code easier to read.

 

Here is how I would type out the action.

 

proc cas;
	loadactionset / actionSet="dataDiscovery";
run;
	dataDiscovery.profile result=r / 
		table={
			name="&table.",
			caslib="&caslib"   /*Specify input caslib. If this is omitted, the active caslib is used */
		},
		casOut={
			name="Profilazione", 
			caslib="&caslib",   /*Specify output caslib. If this is omitted, the active caslib is used */
			replace=true
		};
quit;

 

I also have a series of blogs on CAS actions. Feel free to check out them out: https://blogs.sas.com/content/sgf/2021/08/06/cas-action-a-series-on-fundamentals/

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 1029 views
  • 0 likes
  • 2 in conversation