<?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: converting character date to date9. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/360389#M84844</link>
    <description>&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Sorry for this again. I now can see i have data which has missing or partial and it causes error "2016-06" missing day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In proc report i am mentioning&amp;nbsp;&amp;nbsp;format=datetime7.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and i get all date as 01jan60(for all obs)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;desired format is "06SEP13"&lt;/P&gt;</description>
    <pubDate>Mon, 22 May 2017 09:06:43 GMT</pubDate>
    <dc:creator>vraj1</dc:creator>
    <dc:date>2017-05-22T09:06:43Z</dc:date>
    <item>
      <title>converting character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/360384#M84840</link>
      <description>&lt;P&gt;I have a date variable which is character with length as 50. and i want to convert it to date9.&lt;/P&gt;
&lt;P&gt;sample of date:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;AESTDTC&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;2017-03-14T08:00&lt;/P&gt;
&lt;P&gt;2016-12-16&lt;/P&gt;
&lt;P&gt;2017-04-10T20:00&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i am using the below code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data nkd;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set adae;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; format AESTDT date9.;&lt;BR /&gt; AESTDT = input( AESTDTC, MMDDYY10.);&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i get error as below. can anyone help me out in this&lt;/P&gt;
&lt;P&gt;NOTE: Invalid argument to function INPUT at line 51 column 241.&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 08:45:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/360384#M84840</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-05-22T08:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: converting character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/360385#M84841</link>
      <description>&lt;P&gt;Do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data nkd;
set adae;
format AESTDT date9.;
AESTDT = input(substr(AESTDTC,1,10),yymmdd10.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Although I'd rather expand incomplete timestamps with a default time value and use the e8601dt informat, so that the timestamps are preserved.&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 08:54:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/360385#M84841</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-22T08:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: converting character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/360386#M84842</link>
      <description>&lt;P&gt;like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input AESTDTC $50.;
datalines;
2017-03-14T08:00
2016-12-16
2017-04-10T20:00
;

data want;
	set have;
	date = input(substr(AESTDTC,1,10), yymmdd10.);
	format date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 May 2017 08:55:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/360386#M84842</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-05-22T08:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: converting character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/360389#M84844</link>
      <description>&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Sorry for this again. I now can see i have data which has missing or partial and it causes error "2016-06" missing day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In proc report i am mentioning&amp;nbsp;&amp;nbsp;format=datetime7.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and i get all date as 01jan60(for all obs)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;desired format is "06SEP13"&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 09:06:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/360389#M84844</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-05-22T09:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: converting character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/360390#M84845</link>
      <description>&lt;P&gt;Not sure I understand this, so you have some datapoints where the day of the date is missing?&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 09:08:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/360390#M84845</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-05-22T09:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: converting character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/360394#M84846</link>
      <description>&lt;P&gt;sorry for not being clear.&lt;/P&gt;
&lt;P&gt;Now i made the dates in numeric format date9. as example&amp;nbsp;02JAN2017&lt;/P&gt;
&lt;P&gt;and in proc report for the variable i am using format=date7.; as i need the final date in "06SEP13" but its not working&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 09:17:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/360394#M84846</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-05-22T09:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: converting character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/360395#M84847</link>
      <description>&lt;P&gt;Please post test data in the form of a datastep, I think this has been mentioned several times now.&lt;/P&gt;
&lt;P&gt;First point with any data is to get it into a useable format. &amp;nbsp;What you have there are ISO dates, pretty standard in the SDTM you are displaying there. &amp;nbsp;Now the first question would be what are you doing to want this data, genrally speaking you would goto ADaM first where you can have both the text for display and numerics for calculation. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can however process the data, first, I would have something in the documentation which handles missing or partial dates/times - this is far more important than any coding requirements. &amp;nbsp;Then its simply a matter of implementing these rules. &amp;nbsp;For instance in the below I have assumed 00:00 if time is missing, and all will have 00 for miliseconds as this is not present in the data. &amp;nbsp;Once I apply this rule then handle dates/times formatting becomes the simplest of tasks:&lt;/P&gt;
&lt;PRE&gt;data have;
  length aestdtc $16;
  input aestdtc $;
  aestdtc=cats(aestdtc,"T00:00");
  aestdtc_n=input(cats(aestdtc,":00"),e8601dt.);
  aestdtc_mmddyy=datepart(aestdtc_n);
  format aestdtc_n datetime. aestdtc_mmddyy mmddyy10.;

datalines;
2017-03-14T08:00
2016-12-16
2017-04-10T20:00
;
run;
&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 May 2017 09:21:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/360395#M84847</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-22T09:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: converting character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/360400#M84850</link>
      <description>&lt;P&gt;A couple of items are concerning.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, if you have a variable that takes on date values, why would you try to apply a DATETIME format? &amp;nbsp;That's what gives you 01JAN60. &amp;nbsp;You can use the DATE9 format or the DATE7 format, but not a DATETIME format. &amp;nbsp;Your variable simply isn't storing any time-related information and a pure date should use a date format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, why change the format at all? &amp;nbsp;You already assigned a DATE9 format to your variable. &amp;nbsp;What advantage could you possibly get in your report by shifting to two-digit years?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, it doesn't look like you are telling the full story. &amp;nbsp;What code did you run, so that a missing month should default to SEP?&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 10:26:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/360400#M84850</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-22T10:26:26Z</dc:date>
    </item>
  </channel>
</rss>

