<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to use SAS viya 4 user-defined formats? in SAS Viya</title>
    <link>https://communities.sas.com/t5/SAS-Viya/How-to-use-SAS-viya-4-user-defined-formats/m-p/959929#M2761</link>
    <description>&lt;P&gt;Thanks Mr Santos &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The video is quite good!&amp;nbsp; I followed the instructions and revised the program:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;* One more shot;

proc format library=work.formats casfmtlib="formats";    
  value enginesize 
    low - &amp;lt;2.7 = "Very economical"
    2.7 - &amp;lt;4.1 = "Small"
    4.1 - &amp;lt;5.5 = "Medium"
    5.5 - &amp;lt;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; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I created a new format library 'myFormats'. It is in the search path.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="format_library_search_path.png" style="width: 644px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104837i6E558CBC6215FA49/image-size/large?v=v2&amp;amp;px=999" role="button" title="format_library_search_path.png" alt="format_library_search_path.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But is not working as a permanent format library. I get this error when I try to open the promoted cars dataset:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas_studio_error_no_permanent_format.png" style="width: 509px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104838iB8E503B1EE9B0CCC/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas_studio_error_no_permanent_format.png" alt="sas_studio_error_no_permanent_format.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Feb 2025 15:39:26 GMT</pubDate>
    <dc:creator>LasseL_Knowit</dc:creator>
    <dc:date>2025-02-21T15:39:26Z</dc:date>
    <item>
      <title>How to use SAS viya 4 user-defined formats?</title>
      <link>https://communities.sas.com/t5/SAS-Viya/How-to-use-SAS-viya-4-user-defined-formats/m-p/959600#M2759</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having a problem using my user-defined formats. I have followed the instructions from Gerry Nelson:&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;1) Promoted to global&lt;BR /&gt;2) Added to the Formats path-based CAS library&lt;BR /&gt;3) Added to the CAS server format search path.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;cas casauto sessopts=(caslib="casuser");                    

libname casuser cas caslib="casuser";

proc format library=work.formats casfmtlib="formats";    
  value enginesize 
    low - &amp;lt;2.7 = "Very economical"
    2.7 - &amp;lt;4.1 = "Small"
    4.1 - &amp;lt;5.5 = "Medium"
    5.5 - &amp;lt;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;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I can use the saved format enginesize and I can check my formats should be available:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;* 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; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="check on formats" style="width: 596px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104746i7C135069E0A0A029/image-size/large?v=v2&amp;amp;px=999" role="button" title="fmtlib.png" alt="check on formats" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;check on formats&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;* 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.
*/&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What could be wrong? Any good advice is appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are running SAS Viya on RedHat Openshift (LTS 2024.09)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Br, Lasse&lt;/P&gt;&lt;P&gt;(the program is attached)&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 13:51:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/How-to-use-SAS-viya-4-user-defined-formats/m-p/959600#M2759</guid>
      <dc:creator>LasseL_Knowit</dc:creator>
      <dc:date>2025-02-19T13:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to use SAS viya 4 user-defined formats?</title>
      <link>https://communities.sas.com/t5/SAS-Viya/How-to-use-SAS-viya-4-user-defined-formats/m-p/959757#M2760</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Possibly this SAS Tutorial can help?&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;A href="https://www.youtube.com/watch?v=uC-Z5moTX9k" target="_blank"&gt;SAS Tutorial | Transferring User Defined Formats to CAS&lt;/A&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Regards,&lt;/U&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2025 09:08:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/How-to-use-SAS-viya-4-user-defined-formats/m-p/959757#M2760</guid>
      <dc:creator>MrSantos</dc:creator>
      <dc:date>2025-02-20T09:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to use SAS viya 4 user-defined formats?</title>
      <link>https://communities.sas.com/t5/SAS-Viya/How-to-use-SAS-viya-4-user-defined-formats/m-p/959929#M2761</link>
      <description>&lt;P&gt;Thanks Mr Santos &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The video is quite good!&amp;nbsp; I followed the instructions and revised the program:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;* One more shot;

proc format library=work.formats casfmtlib="formats";    
  value enginesize 
    low - &amp;lt;2.7 = "Very economical"
    2.7 - &amp;lt;4.1 = "Small"
    4.1 - &amp;lt;5.5 = "Medium"
    5.5 - &amp;lt;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; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I created a new format library 'myFormats'. It is in the search path.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="format_library_search_path.png" style="width: 644px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104837i6E558CBC6215FA49/image-size/large?v=v2&amp;amp;px=999" role="button" title="format_library_search_path.png" alt="format_library_search_path.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But is not working as a permanent format library. I get this error when I try to open the promoted cars dataset:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas_studio_error_no_permanent_format.png" style="width: 509px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104838iB8E503B1EE9B0CCC/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas_studio_error_no_permanent_format.png" alt="sas_studio_error_no_permanent_format.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2025 15:39:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/How-to-use-SAS-viya-4-user-defined-formats/m-p/959929#M2761</guid>
      <dc:creator>LasseL_Knowit</dc:creator>
      <dc:date>2025-02-21T15:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to use SAS viya 4 user-defined formats?</title>
      <link>https://communities.sas.com/t5/SAS-Viya/How-to-use-SAS-viya-4-user-defined-formats/m-p/961421#M2781</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Follow up:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If I have both CAS formats and Compute formats it works fine.&amp;nbsp; So, best practice is a ‘duplicate’ set of formats&lt;/P&gt;</description>
      <pubDate>Mon, 10 Mar 2025 13:11:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/How-to-use-SAS-viya-4-user-defined-formats/m-p/961421#M2781</guid>
      <dc:creator>LasseL_Knowit</dc:creator>
      <dc:date>2025-03-10T13:11:14Z</dc:date>
    </item>
  </channel>
</rss>

