I'm adding user defined formats to a table in SAS Studio. The script runs with no errors and a simple.freq command shows me that the formats have been applied. However, when I load the table in SAS VA (Viya), I get an error
"com.sas.cas.CASException: The user-defined programming statements could not be parsed. (severity=2 reason=6 statusCode=2710055) 5 ERROR: The user-defined programming statements could not be parsed. 5 ERROR: Invalid FORMAT 'CONTINUE_EDUC_FILTER.' found. 5 ERROR: Failure opening table 'CPS20082017_FORMATTED' 5 ERROR: The action stopped due to errors. debug=0x887ff837:TKCASTAB_PARSE_ERROR"
-------
There is nothing wrong with the variable or the format and I can run a frequency in SAS Studio. I've used single quotes and double quotes.
value CONTINUE_EDUC_FILTER
0 = 'Total grad school - none' 1 = 'Total grad school (enrolled, planning, or pursuing)' ;
----------
format continue_educ_filter CONTINUE_EDUC_FILTER.;
Any advice would be helpful!
I do not unfortunately.
Ok, questions for you. After you created your custom format in SAS Studio, have you loaded it to the CAS server?
cas casauto promotefmtlib fmtlibname=myCPSformats replace;
.
.
.
format wrk_auth WRK_AUTH.;
load data=work.CPS_2008_2017 casout="CPS20082017_formatted" replace;
contents casdata="CPS20082017_formatted";
run;
quit;
....
proc casutil outcaslib="CASDATA";
promote casdata="CPS20082017_formatted" incaslib="CASDATA";
quit;
Here is the actual code. I've cut back on the number of variables.
cas casauto sessopts=(caslib="casdata");
proc format library=work.formats casfmtlib="myCPSformats";
value AGE_C
1 = '22 or younger'
2 = '23-24'
3 = '25-27'
4 = '28-30'
5 = '31-34'
6 = '35 or older' ;
value COLLFILTER
0 = 'Duplicate Case'
1 = 'Primary Case' ;
value $COMMENTS
'1' = ' ' ;
value CONTINUE_EDUC_FILTER
0 = 'Total grad school - none'
1 = 'Total grad school (enrolled, planning, or pursuing)' ;
value WRK_AUTH
1 = 'Yes'
2 = 'No'
3 = 'Unsure' ;
run;
proc cas;
session casauto;
sessionProp.promoteFmtLib /
fmtLibName="myCPSformats"
replace=true;
run;
quit;
cas casauto promotefmtlib fmtlibname=myCPSformats replace;
cas casauto savefmtlib
fmtlibname=myCPSformats
caslib=casdata
table=myCPSformats replace;
proc casutil;
format AGE_C AGE_C.;
format COLLFILTER COLLFILTER.;
format COMMENTS $COMMENTS.;
format continue_educ_filter CONTINUE_EDUC_FILTER.;
format wrk_auth WRK_AUTH.;
load data=work.CPS_2008_2017 casout="CPS20082017_formatted" replace;
contents casdata="CPS20082017_formatted";
run;
quit;
proc cas ;
columninfo / table={name="CPS20082017_formatted"}; run;
proc casutil outcaslib="CASDATA";
promote casdata="CPS20082017_formatted" incaslib="CASDATA";
quit;
Proc cas;
session casauto;
simple.freq /
inputs={"profempl2013" "yearcode" "continue_educ_filter"}
table={name="CPS20082017_formatted"}
;
run;
quit;
promotefmtlib is good, but you have to run "proc format" before that to generate the SAS format table from your custom format catalog and generate the CAS format library from the SAS format table.
Here is an example:
proc format library=<YOUR_LIBRARY>.formats cntlout=formats_tab;
run;
proc format cntlin=formats_tab casfmtlib="USERFORMATS1";
run;
cas mysession promotefmtlib fmtlibname=USERFORMATS1 replace;
I may be doing something wrong. I tried adding the other proc format statements and I see formats_tab but it's still the same error.
That should work. Try to reach your SAS administrator and get the most recent CAS server log.
I still get the same error and it continues even if I remove the formatted variables causing a problem.
com.sas.cas.CASException: The user-defined programming statements could not be parsed. (severity=2 reason=6 statusCode=2710055) 5 ERROR: The user-defined programming statements could not be parsed. 5 ERROR: Invalid FORMAT 'CONTINUE_EDUC_FILTER.' found. 5 ERROR: Failure opening table 'CPS20082017_FORMATTED'
Does it have something to do with where the formats are? I'm running the results from the cas library not the WORK library and I'm promoting the library but I don't see it in a cas library. I don't get an error either.
It turned out that I was saving the format file as MyCPSFormats and the SAS VA was looking for userformat1. I thought userformat1, userformat2 were examples not the default names.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.
Find more tutorials on the SAS Users YouTube channel.