<?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: Concatenate Char to Formatted Date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-Char-to-Formatted-Date/m-p/455047#M115062</link>
    <description>&lt;P&gt;The crux behind this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp0;
format yest yymmddn8.;
yest = today() - 1;
var1 = 'abc_';
var2 = cat(var1,yest);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is that yest is a numeric variable, while cat() is a string function; so you force SAS to do an automatic conversion from numeric to character, and in such automatic conversions, no formats are applied, and you get the raw value (days from 1960-01-01 to yesterday) appended.&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;'s solution prevents this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hint: never allow automatic type conversions in your programs (you'll find them by the NOTEs they cause). See my Maxims 31 &amp;amp; 25. Take control.&lt;/P&gt;</description>
    <pubDate>Wed, 18 Apr 2018 06:51:16 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-04-18T06:51:16Z</dc:date>
    <item>
      <title>Concatenate Char to Formatted Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-Char-to-Formatted-Date/m-p/455013#M115046</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having trouble keeping a date format when concatenating to a char.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want to attach a char variable to yesterday's date, for example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;abc_20180416.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is the code I made:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data temp0;&lt;/P&gt;&lt;P&gt;yest =today() -1; format yest yymmddn8.;&lt;/P&gt;&lt;P&gt;var1='abc_';&lt;/P&gt;&lt;P&gt;var2= cat(var1,yest);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=temp0 (keep=yest var2);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;yest&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var2&lt;/P&gt;&lt;P&gt;20180416&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; abc_21290;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried a few different things, but can't seem to pin down how to get var2= abc_20180416.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any tips out there?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&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>Wed, 18 Apr 2018 03:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-Char-to-Formatted-Date/m-p/455013#M115046</guid>
      <dc:creator>prolifious</dc:creator>
      <dc:date>2018-04-18T03:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Char to Formatted Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-Char-to-Formatted-Date/m-p/455016#M115047</link>
      <description>&lt;P&gt;Here's the statement that creates VAR2:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;var2= cat(var1,yest);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Try it this way instead:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;var2= cat(var1,put(yest, yymmddn8.));&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Apr 2018 03:33:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-Char-to-Formatted-Date/m-p/455016#M115047</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-04-18T03:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Char to Formatted Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-Char-to-Formatted-Date/m-p/455047#M115062</link>
      <description>&lt;P&gt;The crux behind this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp0;
format yest yymmddn8.;
yest = today() - 1;
var1 = 'abc_';
var2 = cat(var1,yest);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is that yest is a numeric variable, while cat() is a string function; so you force SAS to do an automatic conversion from numeric to character, and in such automatic conversions, no formats are applied, and you get the raw value (days from 1960-01-01 to yesterday) appended.&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;'s solution prevents this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hint: never allow automatic type conversions in your programs (you'll find them by the NOTEs they cause). See my Maxims 31 &amp;amp; 25. Take control.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Apr 2018 06:51:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-Char-to-Formatted-Date/m-p/455047#M115062</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-18T06:51:16Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Char to Formatted Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-Char-to-Formatted-Date/m-p/455119#M115100</link>
      <description>&lt;P&gt;it works.&amp;nbsp; thank you very much for your help here!&lt;/P&gt;</description>
      <pubDate>Wed, 18 Apr 2018 12:15:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-Char-to-Formatted-Date/m-p/455119#M115100</guid>
      <dc:creator>prolifious</dc:creator>
      <dc:date>2018-04-18T12:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Char to Formatted Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-Char-to-Formatted-Date/m-p/455120#M115101</link>
      <description>&lt;P&gt;Thank you, Kurt.&amp;nbsp; These maxims are great!&amp;nbsp; Good reading I'll take up later on.&amp;nbsp; Thanks again for your direction.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Apr 2018 12:15:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-Char-to-Formatted-Date/m-p/455120#M115101</guid>
      <dc:creator>prolifious</dc:creator>
      <dc:date>2018-04-18T12:15:58Z</dc:date>
    </item>
  </channel>
</rss>

