<?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 having any effect in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941505#M369380</link>
    <description>How do I contact sas tech support</description>
    <pubDate>Wed, 28 Aug 2024 16:50:18 GMT</pubDate>
    <dc:creator>Sathya3</dc:creator>
    <dc:date>2024-08-28T16:50:18Z</dc:date>
    <item>
      <title>Truncation of values in column created by case statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941114#M369314</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I am working on a large data&amp;nbsp; where I am creating 150+ columns using case statements in proc sql create table with multiple join conditions. One of the columns which I am creating using case statement is not getting created properly.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Values in this column which I am getting from source are getting truncated even post applying enough format and length.I am left joining main table with the same ref table multiple times but with different joining conditions.I am providing an example for more understanding.It is not the actual code I am using.&lt;/P&gt;
&lt;P&gt;Why are the values in the new column truncated?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example :&lt;/P&gt;
&lt;P&gt;Proc sql;&lt;/P&gt;
&lt;P&gt;create table out as&lt;/P&gt;
&lt;P&gt;case when source.col1 is not null then ref.class&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; when source.col2 is not null then ref1.class&lt;/P&gt;
&lt;P&gt;end as category format $100 length = 100&lt;/P&gt;
&lt;P&gt;from source&lt;/P&gt;
&lt;P&gt;left join table_ref ref&lt;/P&gt;
&lt;P&gt;on&amp;nbsp;source.col3=ref.col3&lt;/P&gt;
&lt;P&gt;left join table_ref ref1&lt;/P&gt;
&lt;P&gt;on&amp;nbsp;source.col4=ref.col4&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 16:39:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941114#M369314</guid>
      <dc:creator>Sathya3</dc:creator>
      <dc:date>2024-08-27T16:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: Truncation of values in column created by case statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941123#M369317</link>
      <description>&lt;P&gt;Please provide code that&amp;nbsp; you have tested that duplicates the problem behavior. When you say "It is not the actual code I am using." then how do we know what may be happening.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Way better would be to provide examples of data sets, as working data step code, that actually demonstrate the behavior. Then we have a chance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some things to consider or share:&lt;/P&gt;
&lt;P&gt;Provide and example of a source value that was truncated. Provide an example of what it was truncated to. Describe which variable, table and variable, this happened to.&lt;/P&gt;
&lt;P&gt;What is the defined length of each of Ref.class and Ref1.class?&lt;/P&gt;
&lt;P&gt;What encoding is the SAS session running? Are any&amp;nbsp; of the source tables external databases? If so, which encoding do those tables store the variables as?&lt;/P&gt;
&lt;P&gt;What does your LOG show for this process? Any warnings or notes about data values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 17:10:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941123#M369317</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-27T17:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: Truncation of values in column created by case statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941208#M369322</link>
      <description>&lt;P&gt;Your join is wrong. You don't use ref1.&lt;/P&gt;
&lt;P&gt;Your whole SQL is invalid (no&amp;nbsp;&lt;CODE class=" language-sas"&gt;select&lt;/CODE&gt; , etc).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check your code, this works as expected*:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data SOURCE;
  retain COL1-COL4 1;
run;

data TABLE_REF;
  retain COL3-COL4 1;
  CLASS=repeat('a',299);
run; 

proc sql;
  create table OUT as
  select case when SOURCE.COL1 is not null then REF.CLASS
              when SOURCE.COL2 is not null then REF1.CLASS
              end as CATEGORY length=300
  from SOURCE
         left join 
       TABLE_REF ref
         on SOURCE.COL3=REF.COL3
         left join 
       TABLE_REF ref1
         on SOURCE.COL4=REF1.COL4
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChrisNZ_0-1724798655976.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/99678iE89B80E0CB76EDF1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChrisNZ_0-1724798655976.png" alt="ChrisNZ_0-1724798655976.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;* Almost as expected. SAS Studio displays a non-existent label. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 22:48:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941208#M369322</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2024-08-27T22:48:13Z</dc:date>
    </item>
    <item>
      <title>Re: Truncation of values in column created by case statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941483#M369357</link>
      <description>An update of the above issue is when I try to create only that column or 3 or 4 columns in addition to that column , truncation is not happening. When I try to create more than 3 or 4 columns in same create table as select statement then values are truncated in that particular column..Very strange issue..and I have defined length as well while creating that column using case statement but it does not seem to have any effect..My source is hive (Hadoop) tables</description>
      <pubDate>Wed, 28 Aug 2024 16:10:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941483#M369357</guid>
      <dc:creator>Sathya3</dc:creator>
      <dc:date>2024-08-28T16:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Truncation of values in column created by case statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941484#M369358</link>
      <description>I can't provide the actual code /data due to privacy policy of my organisation.&lt;BR /&gt;</description>
      <pubDate>Wed, 28 Aug 2024 16:11:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941484#M369358</guid>
      <dc:creator>Sathya3</dc:creator>
      <dc:date>2024-08-28T16:11:41Z</dc:date>
    </item>
    <item>
      <title>Length statement not having any effect</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941485#M369377</link>
      <description>I am creating a dataset by deriving new columns using case statement.My source is in hive (Hadoop)&lt;BR /&gt;Few values are getting truncated for a particular column and length statement does not seem to have any effect.I can't share the actual code /data due to privacy policy of my organisation.Presenting a sample code for understanding &lt;BR /&gt;Example :&lt;BR /&gt;&lt;BR /&gt;Proc sql;&lt;BR /&gt;&lt;BR /&gt;create table out as&lt;BR /&gt;&lt;BR /&gt;case when source.col1 is not null then ref.class&lt;BR /&gt;&lt;BR /&gt;          when source.col2 is not null then ref1.class&lt;BR /&gt;&lt;BR /&gt;end as category format $100. length = 100&lt;BR /&gt;&lt;BR /&gt;from source&lt;BR /&gt;&lt;BR /&gt;left join table_ref ref&lt;BR /&gt;&lt;BR /&gt;on source.col3=ref.col3&lt;BR /&gt;&lt;BR /&gt;left join table_ref ref1&lt;BR /&gt;&lt;BR /&gt;on source.col4=ref.col4&lt;BR /&gt;&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;quit;</description>
      <pubDate>Wed, 28 Aug 2024 16:18:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941485#M369377</guid>
      <dc:creator>Sathya3</dc:creator>
      <dc:date>2024-08-28T16:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement not having any effect</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941486#M369378</link>
      <description>&lt;P&gt;Make up some fake data that illustrates the problem.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2024 16:19:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941486#M369378</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-08-28T16:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement not having any effect</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941497#M369379</link>
      <description>&lt;P&gt;I doubt there is any way we can replicate the behavior of a HADOOP related problem. Perhaps it is time to take this to SAS tech support.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2024 16:33:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941497#M369379</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-28T16:33:11Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement not having any effect</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941505#M369380</link>
      <description>How do I contact sas tech support</description>
      <pubDate>Wed, 28 Aug 2024 16:50:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941505#M369380</guid>
      <dc:creator>Sathya3</dc:creator>
      <dc:date>2024-08-28T16:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement not having any effect</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941507#M369381</link>
      <description>&lt;P&gt;support.sas.com&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2024 16:58:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941507#M369381</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-08-28T16:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement not having any effect</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941535#M369382</link>
      <description>&lt;P&gt;Plese don't re-post the identical question; I merged it into the original thread.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code can&amp;nbsp;&lt;STRONG&gt;NEVER&lt;/STRONG&gt; work, the SQL misses the necessary SELECT.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2024 17:53:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncation-of-values-in-column-created-by-case-statement/m-p/941535#M369382</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-08-28T17:53:53Z</dc:date>
    </item>
  </channel>
</rss>

