<?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: extracting the date using the datepart function?? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146872#M29185</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You just need to insert your variable names in my example. Can't be that complicated, no?&lt;/P&gt;&lt;P&gt;If it does not work, post the log.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Oct 2014 12:07:15 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2014-10-29T12:07:15Z</dc:date>
    <item>
      <title>extracting the date using the datepart function??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146868#M29181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the question data set i have date in as&lt;STRONG&gt; "13may2005:00:00:00.&lt;/STRONG&gt; It is in the &lt;STRONG&gt;character&lt;/STRONG&gt; type. could some one help me how do i extract the date from this using the datepart?? i am new to sas. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for your help &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Oct 2014 10:15:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146868#M29181</guid>
      <dc:creator>koushik</dc:creator>
      <dc:date>2014-10-29T10:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: extracting the date using the datepart function??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146869#M29182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;newdate=datepart(input(olddate,datetime18.));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ie:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;olddate = "13may2005:00:00:00";&lt;/P&gt;&lt;P&gt;format newdate date9.;&lt;/P&gt;&lt;P&gt;newdate=datepart(input(olddate,datetime18.));&lt;/P&gt;&lt;P&gt;put newdate=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Oct 2014 10:23:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146869#M29182</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2014-10-29T10:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: extracting the date using the datepart function??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146870#M29183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for the replay. In my question i have multiple rows.it looks like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;race_date&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;12may2005:00:00:00&lt;/P&gt;&lt;P&gt;04sep2006:00:00:00&lt;/P&gt;&lt;P&gt;27jan2005:00:00:00&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and all i need is to create a new column&lt;STRONG&gt;(new_race_date)&lt;/STRONG&gt; in which the date from the column(race_date) is extracted!! &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for your support!!&lt;/P&gt;&lt;P&gt;koushik.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Oct 2014 11:46:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146870#M29183</guid>
      <dc:creator>koushik</dc:creator>
      <dc:date>2014-10-29T11:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: extracting the date using the datepart function??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146871#M29184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So race_date is a character yes?&amp;nbsp; And you want new_race_date to also be a character yes?&lt;/P&gt;&lt;P&gt;If so then:&lt;/P&gt;&lt;P&gt;data xyx;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set xyx;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new_race_date=scan(race_date,1,':');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;If you want new_race_date to be numeric then:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new_race_date=input(scan(race_date,1,':'),date9.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If race_date is already numeric and you want numeric then:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new_race_date=datepart(race_date);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And for numeric race_date to character new_race_date:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new_race_date=put(datepart(race_date);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Oct 2014 11:50:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146871#M29184</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-10-29T11:50:13Z</dc:date>
    </item>
    <item>
      <title>Re: extracting the date using the datepart function??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146872#M29185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You just need to insert your variable names in my example. Can't be that complicated, no?&lt;/P&gt;&lt;P&gt;If it does not work, post the log.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Oct 2014 12:07:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146872#M29185</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2014-10-29T12:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: extracting the date using the datepart function??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146873#M29186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input race_date $20.;&lt;/P&gt;&lt;P&gt;format new_race_date date9.;&lt;/P&gt;&lt;P&gt;new_race_date=input(race_date,date9.);&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;12may2005:00:00:00&lt;/P&gt;&lt;P&gt;04sep2006:00:00:00&lt;/P&gt;&lt;P&gt;27jan2005:00:00:00&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Oct 2014 12:10:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146873#M29186</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-10-29T12:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: extracting the date using the datepart function??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146874#M29187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Slick!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Oct 2014 13:56:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146874#M29187</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-10-29T13:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: extracting the date using the datepart function??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146875#M29188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It seems you should be most if not all the way there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For me there are two main ways you can use with the date being in a string, firstly input and date part, and secndly substring and input.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is some code demonstrating what i mean.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data source_ds;&lt;/P&gt;&lt;P&gt;input race_date $20.;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;12may2005:00:00:00&lt;/P&gt;&lt;P&gt;04sep2006:00:00:00&lt;/P&gt;&lt;P&gt;27jan2005:00:00:00&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data target_ds;&lt;/P&gt;&lt;P&gt;set source_ds;&lt;/P&gt;&lt;P&gt;format new_race_date date9.;&lt;/P&gt;&lt;P&gt;/* date part method */&lt;/P&gt;&lt;P&gt;new_race_date=datepart(input(race_date,datetime18.));&lt;/P&gt;&lt;P&gt;/* substring method */&lt;/P&gt;&lt;P&gt;new_race_date=input(substr(race_date,1,9),date9.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 16:16:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146875#M29188</guid>
      <dc:creator>Malv72</dc:creator>
      <dc:date>2014-10-30T16:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: extracting the date using the datepart function??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146876#M29189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wow..... really thanks a lot for your support... this worked like a magic..................this is very simple and easy....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you rockkk!!!!! &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 17:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146876#M29189</guid>
      <dc:creator>koushik</dc:creator>
      <dc:date>2014-10-30T17:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: extracting the date using the datepart function??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146877#M29190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for investing your time... you guys are very helpful!!!! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks a lot to all............&amp;nbsp; &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 17:14:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-the-date-using-the-datepart-function/m-p/146877#M29190</guid>
      <dc:creator>koushik</dc:creator>
      <dc:date>2014-10-30T17:14:54Z</dc:date>
    </item>
  </channel>
</rss>

