Exploring, predicting and reporting with SAS Visual Analytics and SAS Visual Statistics

Working with User-Defined Formats with SAS Cloud Analytic Services and SAS Studio

Reply
Occasional Contributor
Posts: 16

Working with User-Defined Formats with SAS Cloud Analytic Services and SAS Studio

[ Edited ]

 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!

 

SAS Super FREQ
Posts: 556

Re: Working with User-Defined Formats with SAS Cloud Analytic Services and SAS Studio

@rjassem1,

 

Do you have an access to the CAS server logs?

Occasional Contributor
Posts: 16

Re: Working with User-Defined Formats with SAS Cloud Analytic Services and SAS Studio

I do not unfortunately. 

SAS Super FREQ
Posts: 556

Re: Working with User-Defined Formats with SAS Cloud Analytic Services and SAS Studio

@rjassem1,

 

Ok, questions for you. After you created your custom format in SAS Studio, have you loaded it to the CAS server? 

Occasional Contributor
Posts: 16

Re: Working with User-Defined Formats with SAS Cloud Analytic Services and SAS Studio

[ Edited ]

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;

Occasional Contributor
Posts: 16

Re: Working with User-Defined Formats with SAS Cloud Analytic Services and SAS Studio

Does it have anything to do with me adding the formats to the WORK library to a table in the WORK library then promoting the formatted table to the cas library? I can't add the formats directly to a table in the cas library.
Occasional Contributor
Posts: 16

Re: Working with User-Defined Formats with SAS Cloud Analytic Services and SAS Studio

[ Edited ]

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;

 

SAS Super FREQ
Posts: 556

Re: Working with User-Defined Formats with SAS Cloud Analytic Services and SAS Studio

@rjassem1,

 

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;
Occasional Contributor
Posts: 16

Re: Working with User-Defined Formats with SAS Cloud Analytic Services and SAS Studio

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. 

SAS Super FREQ
Posts: 556

Re: Working with User-Defined Formats with SAS Cloud Analytic Services and SAS Studio

@rjassem1,

 

That should work. Try to reach your SAS administrator and get the most recent CAS server log.

Occasional Contributor
Posts: 16

Re: Working with User-Defined Formats with SAS Cloud Analytic Services and SAS Studio

[ Edited ]

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.

Occasional Contributor
Posts: 16

Re: Working with User-Defined Formats with SAS Cloud Analytic Services and SAS Studio

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.

Ask a Question
Discussion stats
  • 11 replies
  • 263 views
  • 0 likes
  • 2 in conversation