<?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: day, month and year extraction in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/day-month-and-year-extraction/m-p/333045#M75002</link>
    <description>&lt;P&gt;Since some of your data is not a "date" in any way shape or form you will have to explicitly tell us what "value" you want from a "day" of UN or Month of UNK. From your examples:&lt;/P&gt;
&lt;P&gt;UNFEB2012&lt;BR /&gt;08UNK2016&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also since you say that apparently have inconsistent value for day, your 9 vs 09 comment, provide some examples.&lt;/P&gt;
&lt;P&gt;It helps to provide example data in the first part of your question so we don't have to guess what you have. You example should include example each type of possible malformed value. Do you have UNK for Year? What does it look like.&lt;/P&gt;
&lt;P&gt;And then you should show your desired output for that example data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Feb 2017 15:16:25 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-02-15T15:16:25Z</dc:date>
    <item>
      <title>day, month and year extraction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/day-month-and-year-extraction/m-p/332952#M74987</link>
      <description>&lt;P&gt;How can i extract day , month and year in seperate variables from date9. variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also if date is 9DEC2011 then the day should be *09* instead of just *9* as in some cases the day is single and in some it is 09.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can use functions day() and month() but month() gives month number but i need as it is like DEC for month as shon above&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 11:44:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/day-month-and-year-extraction/m-p/332952#M74987</guid>
      <dc:creator>alexdsa310</dc:creator>
      <dc:date>2017-02-15T11:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: day, month and year extraction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/day-month-and-year-extraction/m-p/332957#M74988</link>
      <description>&lt;P&gt;A day is a number is a number is a number. Numbers don't have leading zeroes.&lt;/P&gt;
&lt;P&gt;If you absolutely need a leading zero, your target variable needs to be a string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;day_string = put(day(datevar),z2.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What format should your months have? If you need the 3-letter name, use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;month = substr(put(datevar,date9.),3,3);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Year is similar to day, just use the year() function and the z4. format.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 11:46:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/day-month-and-year-extraction/m-p/332957#M74988</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-02-15T11:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: day, month and year extraction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/day-month-and-year-extraction/m-p/332976#M74992</link>
      <description>&lt;P&gt;sorry kurt for asking it again. in other case i have data like below and need to do the same operation i.e split day, month and year&lt;/P&gt;&lt;P&gt;17JUL1968&lt;BR /&gt;1JAN2011&lt;BR /&gt;UNFEB2012&lt;BR /&gt;08UNK2016&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the month is missing then it is UNK and if the day is missing it is UN.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I needlike below&lt;/P&gt;&lt;P&gt;D &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;M &amp;nbsp; &amp;nbsp; Y&lt;/P&gt;&lt;P&gt;---------------------&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;17 &amp;nbsp; JUL &amp;nbsp; &amp;nbsp;1968&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;01 &amp;nbsp; &amp;nbsp;JAN &amp;nbsp; 2011&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;UN &amp;nbsp; FEB &amp;nbsp; 2012&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;08 &amp;nbsp; UNK &amp;nbsp; 2016&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 12:31:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/day-month-and-year-extraction/m-p/332976#M74992</guid>
      <dc:creator>alexdsa310</dc:creator>
      <dc:date>2017-02-15T12:31:59Z</dc:date>
    </item>
    <item>
      <title>Re: day, month and year extraction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/day-month-and-year-extraction/m-p/332980#M74993</link>
      <description>&lt;P&gt;You should have stated in your first post that you do not have a SAS date variable, but a string. You only have to use substr() to extract the parts.&lt;/P&gt;
&lt;P&gt;A SAS date value can never have an unknown day or month.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 13:05:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/day-month-and-year-extraction/m-p/332980#M74993</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-02-15T13:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: day, month and year extraction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/day-month-and-year-extraction/m-p/333045#M75002</link>
      <description>&lt;P&gt;Since some of your data is not a "date" in any way shape or form you will have to explicitly tell us what "value" you want from a "day" of UN or Month of UNK. From your examples:&lt;/P&gt;
&lt;P&gt;UNFEB2012&lt;BR /&gt;08UNK2016&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also since you say that apparently have inconsistent value for day, your 9 vs 09 comment, provide some examples.&lt;/P&gt;
&lt;P&gt;It helps to provide example data in the first part of your question so we don't have to guess what you have. You example should include example each type of possible malformed value. Do you have UNK for Year? What does it look like.&lt;/P&gt;
&lt;P&gt;And then you should show your desired output for that example data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 15:16:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/day-month-and-year-extraction/m-p/333045#M75002</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-02-15T15:16:25Z</dc:date>
    </item>
  </channel>
</rss>

