<?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: Proc Format truncating Character Variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-truncating-Character-Variables/m-p/929177#M365605</link>
    <description>Thank you! After defining both in the "format" and the "proc format" with my required widths, it worked.</description>
    <pubDate>Tue, 21 May 2024 18:02:25 GMT</pubDate>
    <dc:creator>Marcus_wong</dc:creator>
    <dc:date>2024-05-21T18:02:25Z</dc:date>
    <item>
      <title>Proc Format truncating Character Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-truncating-Character-Variables/m-p/928730#M365434</link>
      <description>&lt;P&gt;Hi everyone - a bit newer to SAS and running into a problem trying to adapt someone's older code.&lt;/P&gt;&lt;P&gt;Essentially I have a character variable with responses, and am coding in skips to it.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;e.g. Add skip coded 777 into the open text variable OPENTEXT1 if responses are blank&lt;/LI&gt;&lt;LI&gt;OPENTEXT1 has character responses maxing out at 161 characters, proc contents show format=161 informat=$161.&lt;/LI&gt;&lt;LI&gt;Check responses with proc freq, all 777 and responses are normal&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Then I create a "label" using the proc format function with value to label the skip and keep responses&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;proc format; value OPENTEXT '777'="Skip"; run;&lt;/LI&gt;&lt;LI&gt;data dataset1; set dataset; format OPENTEXT $OPENTEXT.&lt;/LI&gt;&lt;LI&gt;proc freq, this time 777 show "SKIP" but other responses truncated to 4 characters&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I checked proc contents, and it is still showing&amp;nbsp;format and informat still remaining at the same length.&lt;/P&gt;&lt;P&gt;Any help appreciated&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 19:39:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-truncating-Character-Variables/m-p/928730#M365434</guid>
      <dc:creator>Marcus_wong</dc:creator>
      <dc:date>2024-05-16T19:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format truncating Character Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-truncating-Character-Variables/m-p/928733#M365437</link>
      <description>&lt;P&gt;If you don't define a DEFAULT width for the format then PROC FORMAT will GUESS that you wanted the default to be the maximum width of all of the display values you mentioned when defining the format.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can specify the width when you use the format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; format OPENTEXT $OPENTEXT20.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that if you don't specify the maximum width it will default to 40 , unless the longest label width is more than 40.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Say your variable named OPENTEXT has a length of 80 then you when you define the format you will want to set the maximum width to at least 80.&amp;nbsp; But you might want to set the default to something shorter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that character format names start with a $.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format; 
value $OPENTEXT (default=40 max=80)
  '777'="Skip"
; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 19:59:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-truncating-Character-Variables/m-p/928733#M365437</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-05-16T19:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format truncating Character Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Format-truncating-Character-Variables/m-p/929177#M365605</link>
      <description>Thank you! After defining both in the "format" and the "proc format" with my required widths, it worked.</description>
      <pubDate>Tue, 21 May 2024 18:02:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Format-truncating-Character-Variables/m-p/929177#M365605</guid>
      <dc:creator>Marcus_wong</dc:creator>
      <dc:date>2024-05-21T18:02:25Z</dc:date>
    </item>
  </channel>
</rss>

