<?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 concat a numeric column into a char with a leading '0' in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/concat-a-numeric-column-into-a-char-with-a-leading-0/m-p/401803#M12207</link>
    <description>&lt;P&gt;&amp;nbsp;I'm processing a table with DI Studio (4.901)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a column that is numeric (best6.) input.. I need to convert the column to character (char40).. (simple enough)&lt;/P&gt;&lt;P&gt;BUT, if the numeric value of the input column is less than/equal to 99.... I need to add a zero to the leading side of the value in it's character result. I have to use this result character column to join with another table..&amp;nbsp; &amp;nbsp;so a value of 99 needs to be '099'&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to use a case statement such as :&lt;/P&gt;&lt;P&gt;case&lt;/P&gt;&lt;P&gt;when &amp;lt;= 99&lt;/P&gt;&lt;P&gt;then cat('0', numeric_column)&lt;/P&gt;&lt;P&gt;else numeric_column&lt;/P&gt;&lt;P&gt;end&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when I try to validate the code I get this error:&lt;/P&gt;&lt;P&gt;71 proc sql;&lt;BR /&gt;72 validate&lt;BR /&gt;73 select case&lt;BR /&gt;74 when &amp;lt;= 99&lt;BR /&gt;__&lt;BR /&gt;22&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,&lt;BR /&gt;a missing value, BTRIM, INPUT, PUT, SUBSTRING, USER.&lt;/P&gt;&lt;P&gt;75 then cat (0, channel_code)&lt;BR /&gt;76 else channel_code&lt;BR /&gt;77 end from work.etls_EFITable;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I'm just overlooking something simple in my logic..&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 06 Oct 2017 14:57:29 GMT</pubDate>
    <dc:creator>cnilsen</dc:creator>
    <dc:date>2017-10-06T14:57:29Z</dc:date>
    <item>
      <title>concat a numeric column into a char with a leading '0'</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/concat-a-numeric-column-into-a-char-with-a-leading-0/m-p/401803#M12207</link>
      <description>&lt;P&gt;&amp;nbsp;I'm processing a table with DI Studio (4.901)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a column that is numeric (best6.) input.. I need to convert the column to character (char40).. (simple enough)&lt;/P&gt;&lt;P&gt;BUT, if the numeric value of the input column is less than/equal to 99.... I need to add a zero to the leading side of the value in it's character result. I have to use this result character column to join with another table..&amp;nbsp; &amp;nbsp;so a value of 99 needs to be '099'&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to use a case statement such as :&lt;/P&gt;&lt;P&gt;case&lt;/P&gt;&lt;P&gt;when &amp;lt;= 99&lt;/P&gt;&lt;P&gt;then cat('0', numeric_column)&lt;/P&gt;&lt;P&gt;else numeric_column&lt;/P&gt;&lt;P&gt;end&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when I try to validate the code I get this error:&lt;/P&gt;&lt;P&gt;71 proc sql;&lt;BR /&gt;72 validate&lt;BR /&gt;73 select case&lt;BR /&gt;74 when &amp;lt;= 99&lt;BR /&gt;__&lt;BR /&gt;22&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,&lt;BR /&gt;a missing value, BTRIM, INPUT, PUT, SUBSTRING, USER.&lt;/P&gt;&lt;P&gt;75 then cat (0, channel_code)&lt;BR /&gt;76 else channel_code&lt;BR /&gt;77 end from work.etls_EFITable;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I'm just overlooking something simple in my logic..&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 14:57:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/concat-a-numeric-column-into-a-char-with-a-leading-0/m-p/401803#M12207</guid>
      <dc:creator>cnilsen</dc:creator>
      <dc:date>2017-10-06T14:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: concat a numeric column into a char with a leading '0'</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/concat-a-numeric-column-into-a-char-with-a-leading-0/m-p/401805#M12208</link>
      <description>&lt;P&gt;You want to use the Z format&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;something like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;charvar=put(numvar,z3.);&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Oct 2017 15:00:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/concat-a-numeric-column-into-a-char-with-a-leading-0/m-p/401805#M12208</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-10-06T15:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: concat a numeric column into a char with a leading '0'</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/concat-a-numeric-column-into-a-char-with-a-leading-0/m-p/401808#M12209</link>
      <description>&lt;P&gt;wow.. that was incredibly quick and painless.&lt;/P&gt;&lt;P&gt;that tried and worked excellent. I'm looking up that Z format to learn more about it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 15:11:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/concat-a-numeric-column-into-a-char-with-a-leading-0/m-p/401808#M12209</guid>
      <dc:creator>cnilsen</dc:creator>
      <dc:date>2017-10-06T15:11:45Z</dc:date>
    </item>
  </channel>
</rss>

