What is PROC CASUTIL and why it is used in SAS?

PROC CASUTILs is a very useful procedure for fiddling around with stuff in the CAS environment. We can list the files and the tables. The tables would be things that are in memory. I’m going to go ahead and run that list. And we’ve noticed that it gives us some great information on where the path is to the actual physical folder that is associated with the CAUSER library. And then we have a boatload of files out there. But when we did the list for the tables, nothing showed up. So notables are loaded in memory. Let’s have a look at the Public library. We can change the CASIO to Public by restarting our CAS session with a new CASIO= specification. And then we can list the things that are in the Public, CALEB. You’ll notice that that does set Public to my active CALLIE.

Now, this one says local equals’ no. That means that this is a global library. We could just as easily list the files and tables in Public by changing this if we were curious. We found that there are no tables available in Public, but there are a couple of offline files that are available out there we could load into memory space if we wanted. Now we can change the CASIO without having to reset the CAS session with a CASIO statement. So we’re going to make a new CASEIN called Bypath. And this is an ad hoc CALIF that is local in scope. This is the data folder. We look at our folders out here in data, there’s a folder called MCAS. We’re going to point our CALEB at that and use that as our offline storage for the CALEB lab called Bypath. And when we create a CASIO with a CALEB statement, it automatically becomes the active CALEB for my CAS session. With this SAS function, GETSESSOPT, you can see that the active CALI is Bypath. Now, what happens when I clear it? It disappears for my CAS session, and you’ll notice that the CAS session never leaves you without an active CASIO. Soon as we cleared the CALEB, Bypath, CAS automatically set CAUSER, our personal CAS library, as the active CALEB again. And that’s our first dive into using CAS libraries.

In lesson two of Programming for SAS Via, we’ll take a look at how to load data into CALEB from the offline storage associated with the CASIO. And also, loading data into the cast lib from files and data sets available to us in the SAS Session. So now that we’ve learned a little about accessing data in Cassius, you’ll probably want to load some files end to the memory space and do some analysis in CAS. Now, before we can do any work with tables in CAS, of course, we have to have the table in memory. And as you can see in this CALEB, there are no in-memory tables loaded. But we have plenty of files in the server that we can use to load tables from. The server-side files reside in that offline storage space that belongs to the CALEB. And they could take many forms. To do analysis with any of those files, we need to load them into memory. Once the files are in memory, we no longer call them files, we call them tables. And tables are what CAS works with. Just like Cassius can have a Session Scope or a Global Scope, so your tables can also have a Session Scope or a Global Scope. The default is Session Scope. What this means is that you’ll see the promoter equals now when you look at the contents of the table. And that table will be visible only to you or whoever it was that created that table in their CAS And when they disconnect from CAS, that table is automatically offloaded from memory. What if I need that table and subsequent sessions? What if others in my group need to share the data with me? In that case, I’ll need a global table. A global table can be promoted to global as you load it, or it can be promoted from an existing Session Scope table.

You’ll know that a table is global in scope because, in the contents, it will show promoted equals yes. This table will be visible across CAS sessions. You can disconnect and reconnect, and still see the table in memory. It will also be visible to any other users to whom the administrator has granted permission. And it will have all the necessary controls like row-level locking to allow that table to be used simultaneously by more than one user. And as we said before, these tables are not dropped from memory when you disconnect from CAS but remain in memory so that next time you connect, there they are. So just as a quick refresher check. If we create a Session Scope table, is it only for us, and are we the only ones that can see it? And will it go away when I disconnect from CAS? The answer to that is, yes, of course. Session Scope tables are only visible to the user who created them. And they’re automatically unloaded from memory as soon as the CAS session disconnects. Global tables, of course, are visible to multiple users and will persist in memory even if you disconnect your CAS session.

Now, maybe the data you want to analyze doesn’t live in CAS. It’s not in the CAS offline storage space or the data sources, but we have access to it in our SAS Session. You can think of the SAS Session here as the client that’s talking to CAS. And so we refer to these types of files as client-side files. We can load these client-side files into CAS tables with the PROC CASUAL LOAD DATA statement with a data equals and your SAS data set name. Hi there. In this demonstration, we’re going to show you how to set up your Autoexec file in SAS Studio so that your CAS session and CAS libraries automatically reconnect themselves every time you start SAS. Then we’re going to load a client-side file, a SAS data set, into CAS and investigate the contents of the in-memory table that we’ve created. In the previous demo, we showed you how to use the path macro variable, MISNAME statements, and CAS and CALEB statements to assign LIBELS, point to local SAS data, and CAS tables.

We’re going to copy this code, and in the Options, we’re going to choose Autoexec File. We’re just going to paste that code in there, and then we’re going to save it. Now to prove this works, I’m going to go ahead and log out of SAS Studio, and then sign back in. Now you’ll notice that all of my CAS libraries that showed up in the previous demo were also showing up here, as well as the SAS library that contains the SAS data sets for this class. So let’s load a SAS data set into CAS. Now, remember, when we do this, it’s going to take data from an existing SAS library and it’s going to load it up into the CAS memory space as Employees. So that means that when we do this, it should show up in the cache user library here. The load went well. And now, we can actually see the CAUSER table that has the employee information. And it matches the information that was in our original Employees table here in the SAS Session.

Leave a comment