<?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: Concat Date and Number Value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385723#M92310</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/28848"&gt;@ertweety&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the help.&lt;/P&gt;
&lt;P&gt;I can't seem to get it to work with either suggestion.&amp;nbsp; I tried different date formats...didn't work.&amp;nbsp; best32. is not recognized as well.&lt;/P&gt;
&lt;P&gt;My data looks as follows;&lt;/P&gt;
&lt;P&gt;dt = 31JAN2017:00:00:00&lt;/P&gt;
&lt;P&gt;xfer_rsn_cd = 100&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My output looks like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1801461916100&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your dt is a datetime value, not a date and when you deal with datetimes the internal representation in SAS is Seconds. You said Date, not time, which in SAS is days from an offset.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you should show EXACTLY what you want to expose to Excel, whether it is numeric or string value, and the starting SAS value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One of my pet peeves is calling a datetime value a date. They are WAY different in any data storage system I am familiar with and you get errors applying DATE functions to DATETIMES and vice versa.&lt;/P&gt;</description>
    <pubDate>Fri, 04 Aug 2017 17:17:32 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-08-04T17:17:32Z</dc:date>
    <item>
      <title>Concat Date and Number Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385683#M92290</link>
      <description>&lt;P&gt;I need to concatenate a SAS date and number to match a concatenated field in excel.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example;&lt;/P&gt;
&lt;P&gt;In excel, my date&amp;nbsp; is 01/31/2017 and the number I want to concatentate with it is 100.&amp;nbsp; When I concatenate these 2 fields, I get 42766100.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How would I concatenate the same 2 values in SAS to return 42766100?&amp;nbsp; The date is datetime in sas but I don't need the time part.&lt;/P&gt;
&lt;P&gt;I have tried all the cat, catx, catq, cats functions to no success.&amp;nbsp; I also tried adding 21916 to my date field but that didn't work either.&amp;nbsp; I'm stuck. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 17:21:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385683#M92290</guid>
      <dc:creator>ertweety</dc:creator>
      <dc:date>2017-08-04T17:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: Concat Date and Number Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385691#M92292</link>
      <description>&lt;PRE&gt;data work.narf;
   a = '31Jan2017'd;
   b = 100;
   c = cat(a+21916 ,b);&lt;BR /&gt;&lt;BR /&gt;   put _all_;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: The log says: a=20850 b=100 c=42766100 _ERROR_=0 _N_=1&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 15:30:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385691#M92292</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2017-08-04T15:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: Concat Date and Number Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385694#M92293</link>
      <description>&lt;P&gt;If you want it to be a number, just expand on&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;'s suggestion:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
  input date mmddyy10.;
  cards;
01/31/2017
;

data want;
  set have;
  newdate=input(catt(date+21916,'100'),best32.);
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 15:38:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385694#M92293</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-08-04T15:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: Concat Date and Number Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385710#M92302</link>
      <description>&lt;P&gt;You are not asking this directly but I am doing some inferring (if I missed it, just ignore).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you deal with datetime values in Excel or SAS, you have to work with the epochal dates to do the conversions correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, Excel has an epochal date of: Jan 1, 1900 unless it is coming from a Mac (it uses 1904). SAS uses Jan 1, 1960. That is the number of ticks/seconds/days since that date. SAS has NO concept of a datetime. it merely uses a double for everything and interprets on the fly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, bottom-line is that if you are trying to do datetime conversions here, ping us back and ask. That is much more complex than doing the concatenation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your example, you are getting the number of days since 1960, not the date, converted into a SAS double. It is better to simply multiply the value times 100 and it achieves the same thing w/o the concatenation cost.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 16:49:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385710#M92302</guid>
      <dc:creator>AlanC</dc:creator>
      <dc:date>2017-08-04T16:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: Concat Date and Number Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385715#M92305</link>
      <description>&lt;P&gt;Thanks for the help.&lt;/P&gt;
&lt;P&gt;I can't seem to get it to work with either suggestion.&amp;nbsp; I tried different date formats...didn't work.&amp;nbsp; best32. is not recognized as well.&lt;/P&gt;
&lt;P&gt;My data looks as follows;&lt;/P&gt;
&lt;P&gt;dt = 31JAN2017:00:00:00&lt;/P&gt;
&lt;P&gt;xfer_rsn_cd = 100&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rsubmit;&lt;BR /&gt;data xfer_cds;&lt;BR /&gt;set xfer_cd;&lt;BR /&gt;cat=catt(dt+21916,xfer_rsn_cd);&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My output looks like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1801461916100&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 17:01:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385715#M92305</guid>
      <dc:creator>ertweety</dc:creator>
      <dc:date>2017-08-04T17:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: Concat Date and Number Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385723#M92310</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/28848"&gt;@ertweety&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the help.&lt;/P&gt;
&lt;P&gt;I can't seem to get it to work with either suggestion.&amp;nbsp; I tried different date formats...didn't work.&amp;nbsp; best32. is not recognized as well.&lt;/P&gt;
&lt;P&gt;My data looks as follows;&lt;/P&gt;
&lt;P&gt;dt = 31JAN2017:00:00:00&lt;/P&gt;
&lt;P&gt;xfer_rsn_cd = 100&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My output looks like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1801461916100&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your dt is a datetime value, not a date and when you deal with datetimes the internal representation in SAS is Seconds. You said Date, not time, which in SAS is days from an offset.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you should show EXACTLY what you want to expose to Excel, whether it is numeric or string value, and the starting SAS value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One of my pet peeves is calling a datetime value a date. They are WAY different in any data storage system I am familiar with and you get errors applying DATE functions to DATETIMES and vice versa.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 17:17:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385723#M92310</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-08-04T17:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: Concat Date and Number Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385725#M92312</link>
      <description>&lt;P&gt;Sorry.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are correct.&amp;nbsp; It is datetime value.&amp;nbsp; However, i don't need the time portion.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 17:19:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385725#M92312</guid>
      <dc:creator>ertweety</dc:creator>
      <dc:date>2017-08-04T17:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: Concat Date and Number Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385730#M92314</link>
      <description>&lt;PRE&gt;data have;
  input date anydtdtm21.;
  cards;
01/31/2017:00:00:00
;

data want;
  set have;
  newdate=input(catt(datepart(date)+21916,100),best32.);
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 17:36:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385730#M92314</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-08-04T17:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Concat Date and Number Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385732#M92316</link>
      <description>&lt;P&gt;Thank you so much for the help!&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 17:44:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385732#M92316</guid>
      <dc:creator>ertweety</dc:creator>
      <dc:date>2017-08-04T17:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: Concat Date and Number Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385737#M92317</link>
      <description>&lt;P&gt;Sub newdate in the above with this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;newdate=(date/86400) || '100';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;86400 is the total number of seconds in a day.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 17:56:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-Date-and-Number-Value/m-p/385737#M92317</guid>
      <dc:creator>AlanC</dc:creator>
      <dc:date>2017-08-04T17:56:13Z</dc:date>
    </item>
  </channel>
</rss>

