<?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: where/when is the actual length of a format label used? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/where-when-is-the-actual-length-of-a-format-label-used/m-p/838672#M331594</link>
    <description>I have the same conclusions as you. I can explain DEFAULT, MIN, MAX too. Not an issue but what I don't know where LENGTH is used for and what was the intention having it in the catalog. My test also when in the direction LENGTH that is the maximal observed/actual length.</description>
    <pubDate>Fri, 14 Oct 2022 17:11:22 GMT</pubDate>
    <dc:creator>xxformat_com</dc:creator>
    <dc:date>2022-10-14T17:11:22Z</dc:date>
    <item>
      <title>where/when is the actual length of a format label used?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/where-when-is-the-actual-length-of-a-format-label-used/m-p/838592#M331559</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The length field (LENGTH in the format catalog) is the actual maximal length in the format LABEL.&lt;/P&gt;
&lt;P&gt;Question: is there any place where this information is used by the SAS system e.g. checking some information, used by an option...&lt;/P&gt;
&lt;P&gt;for me.&lt;/P&gt;
&lt;P&gt;What was the intention when it was decide to store the information in the format catalog?&lt;/P&gt;
&lt;P&gt;I can find explaination with the min, max and default length but not with the actual maximal length.&lt;/P&gt;
&lt;P&gt;I can only imagine extracting the format catalog in a dataset and use this information in a classical manner. But there a lengthn function would likely be sufficient&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
   value ny (default=7) 0='No'
                        1='Yes';
run;

proc format fmtlib;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 09:50:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/where-when-is-the-actual-length-of-a-format-label-used/m-p/838592#M331559</guid>
      <dc:creator>xxformat_com</dc:creator>
      <dc:date>2022-10-14T09:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: where/when is the actual length of a format label used?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/where-when-is-the-actual-length-of-a-format-label-used/m-p/838627#M331573</link>
      <description>&lt;P&gt;I don't really know what LENGTH is used for.&amp;nbsp; MIN, MAX and DEFAULT are the key attributes.&amp;nbsp; DEFAULT says what width to use if the format specification does not include a width.&amp;nbsp; MIN and MAX sets the range of values you can use as the width.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Experiment and see.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
   value ny 
  0='No'
  1='Yes'
  2='Padded '
;
run;

proc format cntlout=formats;
run;

proc print data=formats;
  var fmtname start length min max default label;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Basically the LENGTH seems to be set to the maximum length for any label value.&amp;nbsp; If you don't overwide the DEFAULT length then that will be set to the same thing.&amp;nbsp; It does not appear to make any attempt to figure out how to set MIN and MAX.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 13:29:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/where-when-is-the-actual-length-of-a-format-label-used/m-p/838627#M331573</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-14T13:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: where/when is the actual length of a format label used?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/where-when-is-the-actual-length-of-a-format-label-used/m-p/838638#M331576</link>
      <description>&lt;P&gt;Generally what I run into with custom formats and default length if not supplied in the format definition is that the default display for "long" text gets truncated with the internal default length.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One place that the default may cause unexpected results is when concatenating formatted values when using the || operator or some of the string functions. You may find leading spaces in numeric values displaying formatted values because numeric results will default to right justification in most uses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Max comes into play when someone attempts, whether intentionally or not, to use a very large value for the Width of a format.&lt;/P&gt;
&lt;P&gt;Suppose you accidentally type something like:&amp;nbsp;&amp;nbsp; Format somevar ny2000. ; That is not a syntax error and if your format does not have MAX value less than 2000 SAS will attempt to display Somevar using 2000 characters. Which would be overkill for "yes" or "no". So the default Max of 40 limits the result actually displayed.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 14:43:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/where-when-is-the-actual-length-of-a-format-label-used/m-p/838638#M331576</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-14T14:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: where/when is the actual length of a format label used?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/where-when-is-the-actual-length-of-a-format-label-used/m-p/838647#M331578</link>
      <description>It won't affect numeric much, try playing around with some character formats instead and modifying the length of the created formatted value and the length of the input variable.</description>
      <pubDate>Fri, 14 Oct 2022 15:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/where-when-is-the-actual-length-of-a-format-label-used/m-p/838647#M331578</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-10-14T15:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: where/when is the actual length of a format label used?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/where-when-is-the-actual-length-of-a-format-label-used/m-p/838660#M331582</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184742"&gt;@xxformat_com&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;But there a lengthn function would likely be sufficient&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not in cases where other formats are specified as labels (as in &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p1upn25lbfo6mkn1wncu4dyh9q91.htm#p1qm5zk6r6t9i1n1sq6xpqzp4753" target="_blank" rel="noopener"&gt;Example 4&lt;/A&gt; of the VALUE statement documentation). Then the explicit length specifications of those formats (if any) are taken into account when the length of the new format is determined.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 16:17:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/where-when-is-the-actual-length-of-a-format-label-used/m-p/838660#M331582</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-10-14T16:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: where/when is the actual length of a format label used?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/where-when-is-the-actual-length-of-a-format-label-used/m-p/838672#M331594</link>
      <description>I have the same conclusions as you. I can explain DEFAULT, MIN, MAX too. Not an issue but what I don't know where LENGTH is used for and what was the intention having it in the catalog. My test also when in the direction LENGTH that is the maximal observed/actual length.</description>
      <pubDate>Fri, 14 Oct 2022 17:11:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/where-when-is-the-actual-length-of-a-format-label-used/m-p/838672#M331594</guid>
      <dc:creator>xxformat_com</dc:creator>
      <dc:date>2022-10-14T17:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: where/when is the actual length of a format label used?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/where-when-is-the-actual-length-of-a-format-label-used/m-p/838673#M331595</link>
      <description>&lt;P&gt;You're right I didn't think of that scenario. The lengthn function would not work there.&lt;/P&gt;
&lt;P&gt;I just add an example for future reader of this post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
   value ny (default=7) 0='No'
                        1='Yes';
   value nybis .=' '
               other=[demo10.];
run;

proc format fmtlib;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Oct 2022 17:15:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/where-when-is-the-actual-length-of-a-format-label-used/m-p/838673#M331595</guid>
      <dc:creator>xxformat_com</dc:creator>
      <dc:date>2022-10-14T17:15:10Z</dc:date>
    </item>
  </channel>
</rss>

