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 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)
Follow up:
If I have both CAS formats and Compute formats it works fine. So, best practice is a ‘duplicate’ set of formats
Hello,
Possibly this SAS Tutorial can help?
SAS Tutorial | Transferring User Defined Formats to CAS
Regards,
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.
But is not working as a permanent format library. I get this error when I try to open the promoted cars dataset:
Follow up:
If I have both CAS formats and Compute formats it works fine. So, best practice is a ‘duplicate’ set of formats
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!