BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
LasseL_Knowit
Fluorite | Level 6

Hi,

 

I'm having a problem using my user-defined formats. I have followed the instructions from Gerry Nelson:

To make formats available to the CAS Server SAS catalogs must be converted to a CAS Format Library (sashdat file). The CAS Format Library must be:

1) Promoted to global
2) Added to the Formats path-based CAS library
3) Added to the CAS server format search path.

cas casauto sessopts=(caslib="casuser");                    

libname casuser cas caslib="casuser";

proc format library=work.formats casfmtlib="formats";    
  value enginesize 
    low - <2.7 = "Very economical"
    2.7 - <4.1 = "Small"
    4.1 - <5.5 = "Medium"
    5.5 - <6.9 = "Large"
    6.9 - high = "Very large"
;
run;

* Saving the format to resuse it;
* Saved as enginefmt.sashdat in caslib "casuser";

cas casauto savefmtlib fmtlibname=formats                
   table=enginefmt replace;

* format is added to user-defined format 'fmtlib1';

cas casauto addfmtlib fmtlibname=fmtlib1              
   caslib="casuser"
   table=enginefmt;

* promote fmtlib1 to global scope;

cas casauto promotefmtlib fmtlibname=fmtlib1 replace;

I can use the saved format enginesize and I can check my formats should be available:

 

* use the format enginesize. ;

proc casutil;
  format enginesize enginesize.;                            
  load data=sashelp.cars casout="cars" replace;
  contents casdata="cars";
run;
quit;

/* load a data table to cas under caslib casuser with format enginesize */
proc casutil;
format enginesize enginesize.; 
 load data=sashelp.cars outcaslib="casuser" casout="cars_formatted" 
promote;
quit;

* use and check on formats;

cas casauto listformats scope=global;              

cas casauto fmtsearch=(fmtlib1) position=replace;   

cas casauto listfmtsearch;                         

cas casauto listformats members; 

check on formatscheck on formats

 

If I reset my SAS session or logout/login and then want's to use my saved formats - it is not working. It only works using the work formats:

* use the format enginesize. saved in fmtlib;
* fails - it only works with 'work' caslib formats;


data casuser.cars;
format enginesize enginesize.; 
set casuser.cars_formatted;
run;

/*
80   data casuser.cars;
81   format enginesize enginesize.;
                       -----------
                       48
ERROR 48-59: The format ENGINESIZE was not found or could not be loaded.
82   set casuser.cars_formatted;
83   run;
NOTE: The SAS System stopped processing this step because of errors.
*/


proc casutil;
  format enginesize enginesize.;                            
  load data=sashelp.cars outcaslib="casuser" casout="cars2_formatted" replace;
  contents casdata="cars2_formatted";
run;
quit;

/*
80   proc casutil;
NOTE: The UUID 'ccd385d6-8caa-914c-bbe1-ed21f1423fcc' is connected using session CASAUTO.
81     format enginesize enginesize.;
ERROR: The format ENGINESIZE was not found or could not be loaded.
82     load data=sashelp.cars outcaslib="casuser" casout="cars2_formatted" replace;
83     contents casdata="cars2_formatted";
NOTE: The fileInfo action could not be run for the file "cars2_formatted".
ERROR: The table cars2_formatted could not be located in caslib casuser of Cloud Analytic Services.
ERROR: The action stopped due to errors.
*/

What could be wrong? Any good advice is appreciated 🙂

 

We are running SAS Viya on RedHat Openshift (LTS 2024.09)

 

Br, Lasse

(the program is attached)

1 ACCEPTED SOLUTION

Accepted Solutions
LasseL_Knowit
Fluorite | Level 6

Follow up:

If I have both CAS formats and Compute formats it works fine.  So, best practice is a ‘duplicate’ set of formats

View solution in original post

3 REPLIES 3
MrSantos
SAS Employee

Hello,

Possibly this SAS Tutorial can help?

SAS Tutorial | Transferring User Defined Formats to CAS

 

Regards,

LasseL_Knowit
Fluorite | Level 6

Thanks Mr Santos 🙂

 

The video is quite good!  I followed the instructions and revised the program:

* One more shot;

proc format library=work.formats casfmtlib="formats";    
  value enginesize 
    low - <2.7 = "Very economical"
    2.7 - <4.1 = "Small"
    4.1 - <5.5 = "Medium"
    5.5 - <6.9 = "Large"
    6.9 - high = "Very large"
;
run;

* if more format libs concatenate;

catname allcat (work.formats);

proc format library=work.allcat cntlout=temp;
run;

proc format cntlin=temp sessref=casauto casfmtlib='myFormats';

cas casauto promotefmtlib fmtlibname=myFormats replace;

cas casauto savefmtlib fmtlibname=myFormats table=myFormats replace;

proc casutil;
  format enginesize enginesize.;                            
  load data=sashelp.cars  casout="cars" promote;
  contents casdata="cars";
run;
quit;

cas casauto listformats fmtlibname=myFormats members; 

I created a new format library 'myFormats'. It is in the search path.

format_library_search_path.png

But is not working as a permanent format library. I get this error when I try to open the promoted cars dataset:

sas_studio_error_no_permanent_format.png

LasseL_Knowit
Fluorite | Level 6

Follow up:

If I have both CAS formats and Compute formats it works fine.  So, best practice is a ‘duplicate’ set of formats

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Discussion stats
  • 3 replies
  • 2848 views
  • 0 likes
  • 2 in conversation