<?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: SAS Date Function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Function/m-p/279160#M56230</link>
    <description>&lt;P&gt;It depends on whether your original variable is a numeric SAS date, or a character string.&amp;nbsp; For a numeric SAS date:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;date = datepart(date);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a character string, a good suggestion has already been posted.&amp;nbsp; However, note that it could be simplified.&amp;nbsp; WIthin the context of that earlier suggestion:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;date1 = input(date2, date9.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Either way, apply the FORMAT statement to the resulting variable.&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, 21 Jun 2016 20:58:37 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-06-21T20:58:37Z</dc:date>
    <item>
      <title>SAS Date Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Function/m-p/279151#M56226</link>
      <description>&lt;P&gt;One of my SAS data set gives the date in below format(Datetime24.3)&lt;/P&gt;
&lt;P&gt;How do I convert this to MMDDYY format?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Date&lt;/P&gt;
&lt;P&gt;10Sep2015:13:39:08.000&lt;/P&gt;
&lt;P&gt;10Sep2015:13:45:08.000&lt;/P&gt;
&lt;P&gt;10Sep2015:15:20:08.000&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2016 20:22:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Function/m-p/279151#M56226</guid>
      <dc:creator>skallamp</dc:creator>
      <dc:date>2016-06-21T20:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Function/m-p/279155#M56228</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I have make a simple try. It might work for you.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
input date1 $22.;
datalines;
10Sep2015:13:39:08.000
10Sep2015:13:45:08.000
10Sep2015:15:20:08.000
;
run;


data test2;
set test1 (rename=(date1=date2));
date1=input(substr(date2, 1, 9), date9.);
format date1 MMDDYY10. ;
drop date2;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2016 20:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Function/m-p/279155#M56228</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2016-06-21T20:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Function/m-p/279160#M56230</link>
      <description>&lt;P&gt;It depends on whether your original variable is a numeric SAS date, or a character string.&amp;nbsp; For a numeric SAS date:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;date = datepart(date);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a character string, a good suggestion has already been posted.&amp;nbsp; However, note that it could be simplified.&amp;nbsp; WIthin the context of that earlier suggestion:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;date1 = input(date2, date9.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Either way, apply the FORMAT statement to the resulting variable.&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, 21 Jun 2016 20:58:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Function/m-p/279160#M56230</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-21T20:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Function/m-p/279328#M56287</link>
      <description>&lt;P&gt;Hi Astounding,&lt;/P&gt;&lt;P&gt;Based on your guidance, I have updated the sas code for numeric sas date as :&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
input date1 $22.;
datalines;
10Sep2015:13:39:08.000
10Sep2015:13:45:08.000
10Sep2015:15:20:08.000
;
run;


data test2;
set test1 (rename=(date1=date2));
date3=input(date2, datetime24.3);
date1=datepart(date3);
format date1  MMDDYY10.;
drop date2 date3;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Deepak&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2016 13:46:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Function/m-p/279328#M56287</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2016-06-22T13:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Function/m-p/279369#M56301</link>
      <description>&lt;P&gt;Note that you could have gone directly from date1 to date2:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;date2 = input(date1, date9.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The DATE9 informat instructs the software to reach the first 9 characters of DATE1, when calculating DATE2.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2016 14:53:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Function/m-p/279369#M56301</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-22T14:53:46Z</dc:date>
    </item>
  </channel>
</rss>

