<?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 vs LENGTH: how to avoid data truncation? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-vs-LENGTH-how-to-avoid-data-truncation/m-p/759197#M239862</link>
    <description>&lt;P&gt;You probably want to run something like this after your proc import:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
 value $convert  "No"   ="0"
                 "Yes"  ="1"
                 "U"-"V"="2";

 value $nyu (default=57) "0"= "No"
                         "1"= "Yes"
                         "2"= "Unable to Adjudicate due to...." ;
run;

data WANT(drop=R);
  set HAVE(rename=(RELREC=R));
  attrib RELREC length=$2 format=$nyu.;
  RELREC=put(R,$convert.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Aug 2021 03:48:25 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2021-08-04T03:48:25Z</dc:date>
    <item>
      <title>PROC FORMAT vs LENGTH: how to avoid data truncation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-vs-LENGTH-how-to-avoid-data-truncation/m-p/759165#M239843</link>
      <description>&lt;P&gt;Dear community,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset (imported from xlsx each time when run the program) that has predefined LENGTH for variables to fit all their values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;eg:&amp;nbsp;&lt;BR /&gt;SUBJID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;RELREC&lt;/P&gt;
&lt;P&gt;A100101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&lt;/P&gt;
&lt;P&gt;A100102&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;No&lt;/P&gt;
&lt;P&gt;A100103&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Unable to adjudicate due to insufficient information&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When imported into SAS SUBJID has a length of $27 while RELREC has $57.&amp;nbsp;&lt;BR /&gt;Per my client's data standards (specifications), export dataset must have following LENGTH and FORMAT for above variables:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;VARIABLE&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LENGTH&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;FORMAT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Expected VALUE&lt;/P&gt;
&lt;P&gt;RELREC&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;$2&amp;nbsp; &amp;nbsp;&lt;/STRONG&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;$NYU.&amp;nbsp;&lt;/STRONG&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;STRONG&gt;&amp;nbsp;"0"&lt;/STRONG&gt; ("No")&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;STRONG&gt;&amp;nbsp;"1"&lt;/STRONG&gt; ("Yes")&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;STRONG&gt;&amp;nbsp;"2"&lt;/STRONG&gt; ("Unable to Adjudicate due to....")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My challenge is when applying format and length in DATA step RELREC value is getting truncated and not properly formatted due to data truncation. eg:&lt;/P&gt;
&lt;P&gt;RELREC (formatted)&lt;/P&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;P&gt;Ye&lt;/P&gt;
&lt;P&gt;Un&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To my understanding LENGTH cannot be shorter than the variable's actual value. I tried to assign permanent format at the first data step, then assign length (to a new variable for renaming it later as RELREC) in a different data step. But still getting the same outcome.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope someone from this community had encountered the same issue/or has clear understanding on the behavior of LENGTH vs FORMAT statements and could give some guidance in resolving this issue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Aug 2021 13:13:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-vs-LENGTH-how-to-avoid-data-truncation/m-p/759165#M239843</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2021-08-05T13:13:57Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT vs LENGTH: how to avoid data truncation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-vs-LENGTH-how-to-avoid-data-truncation/m-p/759167#M239845</link>
      <description>&lt;P&gt;Sounds like you need to convert the text in the XLSX file into the values that the format expects.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that you cannot change the LENGTH of a character variable once it is defined.&amp;nbsp; You probably need to create a NEW variable that will have the shorter length.&amp;nbsp; You can always rename it to have the desired name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  length new_relrec $2;
  if relrec='No' then new_relrec='0';
  else if relrec='Yes' then new_relrec='1';
  else if relrec=:'Unable to' then new_relrec='2';
  drop relrec;
  rename new_relrec = relrec;
  format new_relres $nyu.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In SAS formats are used to convert values to text and informats are used to convert text to values.&amp;nbsp; Since your values are text you could create either an INFORMAT or a format.&amp;nbsp; So you might create an informat named $NYUI or a format named $NYUR and then replace the IF/THEN/ELSE block with simple assignment statement.&amp;nbsp; Like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new_relec=input(relrec,$nyuI.);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new_relrec=put(relrec,$nyuR.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt; that in this case since the first two characters of the decoded values you are starting with is enough to uniquely identify the codes you want to map to could skip the renaming part.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  length relrec $2;
  set have;
  if relrec='No' then relrec='0';
  else if relrec='Ye' then relrec='1';
  else if relrec='Un' then relrec='2';
  format relres $nyu.;
run;  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Aug 2021 00:02:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-vs-LENGTH-how-to-avoid-data-truncation/m-p/759167#M239845</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-08-04T00:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT vs LENGTH: how to avoid data truncation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-vs-LENGTH-how-to-avoid-data-truncation/m-p/759173#M239849</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your input!&lt;/P&gt;
&lt;P&gt;What I did not understand is I've created format for "YES", "NO" and "UNABLE TO.." values.&lt;/P&gt;
&lt;P&gt;like:&lt;/P&gt;
&lt;DIV&gt;proc format;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;value $nyu "NO"= "0"&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "YES"= "1"&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"UNABLE TO ADJUDICATE DUE TO INSUFFICIENT INFORMATION"= "2";&lt;/DIV&gt;
&lt;DIV&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;P&gt;In your example below the format is applied to "0", "1" and "2" values of new_relrec variable (not to 'yes', 'no' 'unable to..')..... It does give me desired METADATA (when checked in proc contents), however I did not understand the logic here.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;data want;
  set have;
  length new_relrec $2;
  if relrec='No' then new_relrec='0';
  else if relrec='Yes' then new_relrec='1';
  else if relrec=:'Unable to' then new_relrec='2';
  drop relrec;
  rename new_relrec = relrec;
  format new_relres $nyu.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Aug 2021 01:08:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-vs-LENGTH-how-to-avoid-data-truncation/m-p/759173#M239849</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2021-08-04T01:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT vs LENGTH: how to avoid data truncation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-vs-LENGTH-how-to-avoid-data-truncation/m-p/759197#M239862</link>
      <description>&lt;P&gt;You probably want to run something like this after your proc import:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
 value $convert  "No"   ="0"
                 "Yes"  ="1"
                 "U"-"V"="2";

 value $nyu (default=57) "0"= "No"
                         "1"= "Yes"
                         "2"= "Unable to Adjudicate due to...." ;
run;

data WANT(drop=R);
  set HAVE(rename=(RELREC=R));
  attrib RELREC length=$2 format=$nyu.;
  RELREC=put(R,$convert.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Aug 2021 03:48:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-vs-LENGTH-how-to-avoid-data-truncation/m-p/759197#M239862</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-08-04T03:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT vs LENGTH: how to avoid data truncation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-vs-LENGTH-how-to-avoid-data-truncation/m-p/759215#M239871</link>
      <description>&lt;P&gt;In a &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/p1upn25lbfo6mkn1wncu4dyh9q91.htm" target="_blank" rel="noopener"&gt;VALUE Statement&lt;/A&gt; in the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/p1xidhqypi0fnwn1if8opjpqpbmn.htm" target="_blank" rel="noopener"&gt;FORMAT Procedure&lt;/A&gt;, the source value has to be on the left of the equal sign, and the target value to the right.&lt;/P&gt;
&lt;P&gt;Your format, as defined, could be used for the initial conversion, if the source text was in all uppercase.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Aug 2021 06:28:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-vs-LENGTH-how-to-avoid-data-truncation/m-p/759215#M239871</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-08-04T06:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT vs LENGTH: how to avoid data truncation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-vs-LENGTH-how-to-avoid-data-truncation/m-p/759353#M239968</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this example '0', '1', '2' are treated as source values. And they get formatted into "Yes", "No" and "Unable to..".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My problem is the opposite of this. "Yes", "No" and "Unable to.." are source values.. I need to format them into '0', '1' and '2' and fit the string in $2 length.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;'s example works, in one hand, to create a new variable with the length of $2 and conditionally convert RELREC values into "0", "1" and "2" of new variable, and rename it as RELREC. Then apply $NYU. format... But the formatted value is not the original value here. When format removed you cannot see "Yes", "No" and "Unable to.." values...&lt;/P&gt;</description>
      <pubDate>Wed, 04 Aug 2021 14:37:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-vs-LENGTH-how-to-avoid-data-truncation/m-p/759353#M239968</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2021-08-04T14:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT vs LENGTH: how to avoid data truncation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-vs-LENGTH-how-to-avoid-data-truncation/m-p/759533#M240035</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;In this example '0', '1', '2' are treated as source values. And they get formatted into "Yes", "No" and "Unable to..".&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Not at all. The full string is transformed into a new variable containing the digit string, and a format is associated with the new string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  input SUBJID $8. RELREC $80.;
cards;
A100101 Yes                                                                             
A100102 No                                                                                            
A100103 Unable to adjudicate due to insufficient information
run;

proc format ;
 value $convert  "No"   ="0"
                 "Yes"  ="1"
                 "U"-"V"="2";

 value $nyu (default=57) "0"= "No"
                         "1"= "Yes"
                         "2"= "Unable to Adjudicate due to...." ;
run;

data WANT(drop=R);
  set HAVE(rename=(RELREC=R));
  attrib RELREC length=$2 format=$nyu.;
  RELREC=put(R,$convert.);
run;

proc print; proc contents; run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;Obs&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;SUBJID&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;RELREC&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="l data"&gt;A100101&lt;/TD&gt;
&lt;TD class="l data"&gt;Yes&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;2&lt;/TH&gt;
&lt;TD class="l data"&gt;A100102&lt;/TD&gt;
&lt;TD class="l data"&gt;No&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;3&lt;/TH&gt;
&lt;TD class="l data"&gt;A100103&lt;/TD&gt;
&lt;TD class="l data"&gt;Unable to Adjudicate due to....&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="branch"&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR size="3" /&gt;
&lt;DIV class="l proctitle"&gt;The CONTENTS Procedure&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Contents: Attributes" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Data Set Name&lt;/TH&gt;
&lt;TD class="l data"&gt;WORK.WANT&lt;/TD&gt;
&lt;TH class="l rowheader" scope="row"&gt;Observations&lt;/TH&gt;
&lt;TD class="l data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Member Type&lt;/TH&gt;
&lt;TD class="l data"&gt;DATA&lt;/TD&gt;
&lt;TH class="l rowheader" scope="row"&gt;Variables&lt;/TH&gt;
&lt;TD class="l data"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Engine&lt;/TH&gt;
&lt;TD class="l data"&gt;V9&lt;/TD&gt;
&lt;TH class="l rowheader" scope="row"&gt;Indexes&lt;/TH&gt;
&lt;TD class="l data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Created&lt;/TH&gt;
&lt;TD class="l data"&gt;05/08/2021 09:48:32&lt;/TD&gt;
&lt;TH class="l rowheader" scope="row"&gt;Observation Length&lt;/TH&gt;
&lt;TD class="l data"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Last Modified&lt;/TH&gt;
&lt;TD class="l data"&gt;05/08/2021 09:48:32&lt;/TD&gt;
&lt;TH class="l rowheader" scope="row"&gt;Deleted Observations&lt;/TH&gt;
&lt;TD class="l data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Protection&lt;/TH&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TH class="l rowheader" scope="row"&gt;Compressed&lt;/TH&gt;
&lt;TD class="l data"&gt;NO&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Data Set Type&lt;/TH&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TH class="l rowheader" scope="row"&gt;Sorted&lt;/TH&gt;
&lt;TD class="l data"&gt;NO&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Label&lt;/TH&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TH class="l rowheader" scope="row"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Data Representation&lt;/TH&gt;
&lt;TD class="l data"&gt;WINDOWS_64&lt;/TD&gt;
&lt;TH class="l rowheader" scope="row"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Encoding&lt;/TH&gt;
&lt;TD class="l data"&gt;wlatin1 Western (Windows)&lt;/TD&gt;
&lt;TH class="l rowheader" scope="row"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Contents: Engine/Host Information" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c b header" colspan="2" scope="colgroup"&gt;Engine/Host Dependent Information&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Data Set Page Size&lt;/TH&gt;
&lt;TD class="l data"&gt;131072&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Number of Data Set Pages&lt;/TH&gt;
&lt;TD class="l data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;First Data Page&lt;/TH&gt;
&lt;TD class="l data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Max Obs per Page&lt;/TH&gt;
&lt;TD class="l data"&gt;12943&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Obs in First Data Page&lt;/TH&gt;
&lt;TD class="l data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Number of Data Set Repairs&lt;/TH&gt;
&lt;TD class="l data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Filename&lt;/TH&gt;
&lt;TD class="l data"&gt;K:\SASWORK\_TD17820_NZ8037SPSAS2003_\Prc2\want.sas7bdat&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Release Created&lt;/TH&gt;
&lt;TD class="l data"&gt;9.0401M2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Host Created&lt;/TH&gt;
&lt;TD class="l data"&gt;X64_SRV12&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Contents: Variables" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c b header" colspan="5" scope="colgroup"&gt;Alphabetic List of Variables and Attributes&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r b header" scope="col"&gt;#&lt;/TH&gt;
&lt;TH class="l b header" scope="col"&gt;Variable&lt;/TH&gt;
&lt;TH class="l b header" scope="col"&gt;Type&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;Len&lt;/TH&gt;
&lt;TH class="l b header" scope="col"&gt;Format&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;&lt;FONT face="arial black,avant garde" color="#FF0000"&gt;2&lt;/FONT&gt;&lt;/TH&gt;
&lt;TD class="l data"&gt;&lt;FONT face="arial black,avant garde" color="#FF0000"&gt;RELREC&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD class="l data"&gt;&lt;FONT face="arial black,avant garde" color="#FF0000"&gt;Char&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD class="r data"&gt;&lt;FONT face="arial black,avant garde" color="#FF0000"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD class="l data"&gt;&lt;FONT face="arial black,avant garde" color="#FF0000"&gt;$NYU.&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="l data"&gt;SUBJID&lt;/TD&gt;
&lt;TD class="l data"&gt;Char&lt;/TD&gt;
&lt;TD class="r data"&gt;8&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Aug 2021 21:51:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-vs-LENGTH-how-to-avoid-data-truncation/m-p/759533#M240035</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-08-04T21:51:53Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT vs LENGTH: how to avoid data truncation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-vs-LENGTH-how-to-avoid-data-truncation/m-p/759565#M240054</link>
      <description>&lt;P&gt;I see this gives required attributes as format and length, not "the formatted value" which is "0", "1" and "2". In your print results we still see original values "Yes", "No" and "Unable..."..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just modified formatting part of your code and see I'm getting both required metadata and value:&lt;/P&gt;
&lt;P&gt;proc format;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;value $nyu (default=57)&amp;nbsp; &amp;nbsp;"No"= "0"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "Yes"= "1"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "Unable to ........."= "2";&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data WANT(drop=R);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;set HAVE(rename=(RELREC=R));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;attrib RELREC length=$2 format=$nyu. ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;RELREC=put(R,$nyu.);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print; proc contents; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Couldn't paste contents results here...Please check it and give your feedback.&amp;nbsp; Appreciate your support!&lt;/P&gt;</description>
      <pubDate>Wed, 04 Aug 2021 23:50:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-vs-LENGTH-how-to-avoid-data-truncation/m-p/759565#M240054</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2021-08-04T23:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT vs LENGTH: how to avoid data truncation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-vs-LENGTH-how-to-avoid-data-truncation/m-p/759569#M240058</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;I see this gives required attributes as format and length, not "the formatted value" which is "0", "1" and "2".&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You want a length of $2. Therefore the &lt;EM&gt;unformatted&lt;/EM&gt; value can only be 0, 1, 2 and the &lt;EM&gt;formatted&lt;/EM&gt; value is the text.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Aug 2021 00:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-vs-LENGTH-how-to-avoid-data-truncation/m-p/759569#M240058</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-08-05T00:07:44Z</dc:date>
    </item>
  </channel>
</rss>

