<?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: Length statement not working in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Length-statement-not-working/m-p/925107#M44651</link>
    <description>&lt;P&gt;That is the same program you started with.&lt;/P&gt;
&lt;P&gt;Perhaps it works now because GETA is different now than it was before?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The logic of your code is still broken.&amp;nbsp; Consider an observation with (bus="rnm" and ent ne 'lfs') then the first IF/THEN will set ENT1 to&amp;nbsp;'soc'.&amp;nbsp; But then the next IF/THEN/ELSE block will set it to whatever value the ENT had before.&amp;nbsp; Which value do you want in that case?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: You do NOT want to drop ENT on the way in because your code is using the values of ENT in its logic.&amp;nbsp; If GETA might or might not have the ENT1 variable you could adjust the setting of the DKRICOND system option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;H2 id="n094b9k7qgevhen17cnbvxpra5gy" class="xis-title"&gt;Syntax&lt;/H2&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV class="xis-syntaxSimple"&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV class="xis-syntaxLevel"&gt;&lt;SPAN class="xis-keyword"&gt;DKRICOND=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xis-argRequired"&gt;&lt;SPAN class="xis-choice"&gt;&lt;A tabindex="0" href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/lesysoptsref/p11ksgdhjx7369n1dpiry84z7gjn.htm#p0xyecnxson3jyn131ixz44bv66k" target="_blank" rel="noopener"&gt;ERROR&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class="xis-choice"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;|&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A tabindex="0" href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/lesysoptsref/p11ksgdhjx7369n1dpiry84z7gjn.htm#n01wkx6g5fq35dn1usywusuxa3hf" target="_blank" rel="noopener"&gt;WARN&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class="xis-choice"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;|&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A tabindex="0" href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/lesysoptsref/p11ksgdhjx7369n1dpiry84z7gjn.htm#n01wkx6g5fq35dn1usywusuxa3hf" target="_blank" rel="noopener"&gt;WARNING&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class="xis-choice"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;|&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A tabindex="0" href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/lesysoptsref/p11ksgdhjx7369n1dpiry84z7gjn.htm#n0uphtf4u2imhsn1g2vmotvq97a2" target="_blank" rel="noopener"&gt;NOWARN&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class="xis-choice"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;|&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A tabindex="0" href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/lesysoptsref/p11ksgdhjx7369n1dpiry84z7gjn.htm#n0uphtf4u2imhsn1g2vmotvq97a2" target="_blank" rel="noopener"&gt;NOWARNING&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/DIV&gt;</description>
    <pubDate>Sat, 20 Apr 2024 22:24:44 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-04-20T22:24:44Z</dc:date>
    <item>
      <title>Length statement not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Length-statement-not-working/m-p/925102#M44648</link>
      <description>&lt;P&gt;I am trying to replace blanks in a column by creating a new column - "ent1" but the value "The Hav" is not carrying over as "The Hav",&lt;BR /&gt;it's carrying over as "The ". I tried doing length, format and informat but it still shows as "The " in the output. When checking the &lt;BR /&gt;properties for the new field "ent1", it still shows length as 3 and format and informat as $10.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data getb;
set geta;&lt;BR /&gt;
length ent1 $10.;
format ent1 $10.;
informat ent1 $10.;&lt;BR /&gt;
if bus="rnm" and ent ne 'lfs' then ent1='soc';

if bus='snc' and ent = '' then ent1='snc';
else ent1=ent;

if ent1 = 'The ' then ent1 = 'The Hav';
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Apr 2024 20:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Length-statement-not-working/m-p/925102#M44648</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2024-04-20T20:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Length-statement-not-working/m-p/925104#M44649</link>
      <description>&lt;P&gt;The only reason that ENT1 would not have a length of $10 in GETB is if ENT1 already existed in GETB.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try dropping it on the way in.&amp;nbsp; There is no need to include a period in the LENGTH statement, lengths are always integers. There is no need to attach either an informat nor a format to normal character variables.&amp;nbsp; SAS does not need special instructions for display them.&amp;nbsp; And since you are not actually reading in data there is no need for an informat at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your second IF statement (the one with the ELSE statement associated) will override any choices made by the first.&amp;nbsp; Perhaps you need another ELSE?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data getb;
  set geta(drop=ent1);
  length ent1 $10;
  if bus="rnm" and ent ne 'lfs' then ent1='soc';
  else if bus='snc' and ent = '' then ent1='snc';
  else ent1=ent;

  if ent1 = 'The ' then ent1 = 'The Hav';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Apr 2024 21:03:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Length-statement-not-working/m-p/925104#M44649</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-20T21:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Length-statement-not-working/m-p/925106#M44650</link>
      <description>&lt;P&gt;Thank you! This worked for me without the else or drop (ent1 is the new column; i assume you meant that I should drop ent instead which is the orig column):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data getb ;
set geta;
length ent1 $10;

if bus="rnm" and ent ne 'lfs' then ent1='soc';

if bus='snc' and ent = '' then ent1='snc';
else ent1=ent;

if ent1 = 'The ' then ent1 = 'The Hav';
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Apr 2024 21:48:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Length-statement-not-working/m-p/925106#M44650</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2024-04-20T21:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Length-statement-not-working/m-p/925107#M44651</link>
      <description>&lt;P&gt;That is the same program you started with.&lt;/P&gt;
&lt;P&gt;Perhaps it works now because GETA is different now than it was before?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The logic of your code is still broken.&amp;nbsp; Consider an observation with (bus="rnm" and ent ne 'lfs') then the first IF/THEN will set ENT1 to&amp;nbsp;'soc'.&amp;nbsp; But then the next IF/THEN/ELSE block will set it to whatever value the ENT had before.&amp;nbsp; Which value do you want in that case?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: You do NOT want to drop ENT on the way in because your code is using the values of ENT in its logic.&amp;nbsp; If GETA might or might not have the ENT1 variable you could adjust the setting of the DKRICOND system option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;H2 id="n094b9k7qgevhen17cnbvxpra5gy" class="xis-title"&gt;Syntax&lt;/H2&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV class="xis-syntaxSimple"&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV class="xis-syntaxLevel"&gt;&lt;SPAN class="xis-keyword"&gt;DKRICOND=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xis-argRequired"&gt;&lt;SPAN class="xis-choice"&gt;&lt;A tabindex="0" href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/lesysoptsref/p11ksgdhjx7369n1dpiry84z7gjn.htm#p0xyecnxson3jyn131ixz44bv66k" target="_blank" rel="noopener"&gt;ERROR&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class="xis-choice"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;|&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A tabindex="0" href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/lesysoptsref/p11ksgdhjx7369n1dpiry84z7gjn.htm#n01wkx6g5fq35dn1usywusuxa3hf" target="_blank" rel="noopener"&gt;WARN&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class="xis-choice"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;|&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A tabindex="0" href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/lesysoptsref/p11ksgdhjx7369n1dpiry84z7gjn.htm#n01wkx6g5fq35dn1usywusuxa3hf" target="_blank" rel="noopener"&gt;WARNING&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class="xis-choice"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;|&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A tabindex="0" href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/lesysoptsref/p11ksgdhjx7369n1dpiry84z7gjn.htm#n0uphtf4u2imhsn1g2vmotvq97a2" target="_blank" rel="noopener"&gt;NOWARN&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class="xis-choice"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;|&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A tabindex="0" href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/lesysoptsref/p11ksgdhjx7369n1dpiry84z7gjn.htm#n0uphtf4u2imhsn1g2vmotvq97a2" target="_blank" rel="noopener"&gt;NOWARNING&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sat, 20 Apr 2024 22:24:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Length-statement-not-working/m-p/925107#M44651</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-20T22:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Length-statement-not-working/m-p/925108#M44652</link>
      <description>&lt;P&gt;This is what the data looked like before (blanks in rnm and snc) then I wanted to bring in the rest of the values from ent into ent1 column and use ent1 the rest of the program:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;bus&amp;nbsp; &amp;nbsp; ent&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;rnm&amp;nbsp; &amp;nbsp; lfs&lt;/P&gt;
&lt;P&gt;rnm&amp;nbsp; &amp;nbsp; lfs&lt;/P&gt;
&lt;P&gt;rnm&lt;/P&gt;
&lt;P&gt;rnm&lt;/P&gt;
&lt;P&gt;snc&amp;nbsp; &amp;nbsp; snc&lt;/P&gt;
&lt;P&gt;snc&lt;/P&gt;
&lt;P&gt;snc&lt;/P&gt;
&lt;P&gt;ine&amp;nbsp; &amp;nbsp; The Havens&lt;/P&gt;
&lt;P&gt;ine&amp;nbsp; &amp;nbsp; The Havens&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Apr 2024 22:37:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Length-statement-not-working/m-p/925108#M44652</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2024-04-20T22:37:18Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Length-statement-not-working/m-p/925111#M44654</link>
      <description>&lt;P&gt;Actually, now i see what you're saying. Thank you it worked!&lt;/P&gt;</description>
      <pubDate>Sun, 21 Apr 2024 00:10:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Length-statement-not-working/m-p/925111#M44654</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2024-04-21T00:10:29Z</dc:date>
    </item>
  </channel>
</rss>

