<?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 Retrieve date month and year in seperate variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Retrieve-date-month-and-year-in-seperate-variables/m-p/134134#M36402</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How do I retrieve date, month and year in seperate variables. I have to use a if condition.. and i need those values to be stored in a variable seperately.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 May 2013 20:10:46 GMT</pubDate>
    <dc:creator>Meera</dc:creator>
    <dc:date>2013-05-14T20:10:46Z</dc:date>
    <item>
      <title>Retrieve date month and year in seperate variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Retrieve-date-month-and-year-in-seperate-variables/m-p/134134#M36402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How do I retrieve date, month and year in seperate variables. I have to use a if condition.. and i need those values to be stored in a variable seperately.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 May 2013 20:10:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Retrieve-date-month-and-year-in-seperate-variables/m-p/134134#M36402</guid>
      <dc:creator>Meera</dc:creator>
      <dc:date>2013-05-14T20:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve date month and year in seperate variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Retrieve-date-month-and-year-in-seperate-variables/m-p/134135#M36403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could try date functions as below&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data _null_;&lt;/P&gt;&lt;P&gt;dob='19may2013'd;&lt;/P&gt;&lt;P&gt;day=day(dob);&lt;/P&gt;&lt;P&gt;month=month(dob);&lt;/P&gt;&lt;P&gt;year=year(dob);&lt;/P&gt;&lt;P&gt;put dob day month year;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 May 2013 20:29:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Retrieve-date-month-and-year-in-seperate-variables/m-p/134135#M36403</guid>
      <dc:creator>Arul</dc:creator>
      <dc:date>2013-05-14T20:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve date month and year in seperate variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Retrieve-date-month-and-year-in-seperate-variables/m-p/134136#M36404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why do you want to separate it and how is your date stored?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 May 2013 21:03:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Retrieve-date-month-and-year-in-seperate-variables/m-p/134136#M36404</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-05-14T21:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve date month and year in seperate variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Retrieve-date-month-and-year-in-seperate-variables/m-p/134137#M36405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a dataset with a date variable (yyyy/mm/dd). There are 30 rows for that variable. I have to generate a report to check each row and see if date and mon are specific value then display a text if not display something else. I am new to sas.. so I would appreciate any feedback from you. I am thinking of using Substr function. One of my friend used macro and used a substr and i think its too complex. I am trying to use sas code efficiently. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 May 2013 02:55:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Retrieve-date-month-and-year-in-seperate-variables/m-p/134137#M36405</guid>
      <dc:creator>Meera</dc:creator>
      <dc:date>2013-05-15T02:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve date month and year in seperate variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Retrieve-date-month-and-year-in-seperate-variables/m-p/134138#M36406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I recommend reading this paper:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.lexjansen.com/pharmasug/2005/tutorials/tu01.pdf" title="http://www.lexjansen.com/pharmasug/2005/tutorials/tu01.pdf"&gt;http://www.lexjansen.com/pharmasug/2005/tutorials/tu01.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, you should verify if it is a date variable or a character variable. &lt;/P&gt;&lt;P&gt;Run a proc contents on the data and examine the results for the variable of interest. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Usually it's better to use the built in SAS date functions rather than separate it out if possible, but you haven't provided enough information to comment on that. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc contents data=have;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 May 2013 03:19:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Retrieve-date-month-and-year-in-seperate-variables/m-p/134138#M36406</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-05-15T03:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve date month and year in seperate variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Retrieve-date-month-and-year-in-seperate-variables/m-p/134139#M36407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial, sans-serif; font-size: 11px; background-color: #d9d9d9;"&gt;Display the values in DDMONYYYY format. If there are ANS for date and month fields, display them as ANS/ANS/YYYY.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial, sans-serif; font-size: 11px; background-color: #d9d9d9;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial, sans-serif; font-size: 11px; background-color: #d9d9d9;"&gt;This is my scenario. My date variable is stored as character and yyyy/mm/dd format. Can you help me? Let me know if you need more info&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2013 15:22:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Retrieve-date-month-and-year-in-seperate-variables/m-p/134139#M36407</guid>
      <dc:creator>Meera</dc:creator>
      <dc:date>2013-05-16T15:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve date month and year in seperate variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Retrieve-date-month-and-year-in-seperate-variables/m-p/134140#M36408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Create a SAS date variable first using:&lt;/P&gt;&lt;P&gt;NewDateVar = input(yourdatecharactervarname, yymmdd10.);&lt;/P&gt;&lt;P&gt;Format NewDateVar ddmonyy9.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then use Arul's approach.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BTW, if the date is not a valid date then NewDateVar above will be missing and you'll warnings in the log.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure what you mean by ANS.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2013 15:39:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Retrieve-date-month-and-year-in-seperate-variables/m-p/134140#M36408</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-05-16T15:39:14Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve date month and year in seperate variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Retrieve-date-month-and-year-in-seperate-variables/m-p/134141#M36409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you're trying to deal with dates that have missing parts (e.g missing day or month) then I think you'll need to roll your own format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The ideal solution would be to create a format that would handle the missing portions, but I'm not aware of how to do that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The brute force methodology is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to substr to partition the dates into the day/month/year.&lt;/P&gt;&lt;P&gt;Map month number to 3 digit short name.&lt;/P&gt;&lt;P&gt;Check for missing fields.&lt;/P&gt;&lt;P&gt;If missing the create char as first format, if not then put in other format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a presentation on getting some of that, and the paper above would be useful:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sas.com/offices/NA/canada/downloads/UserGroups/eSUG-May2013/Eberhardt-PerlPPT.pdf" title="http://www.sas.com/offices/NA/canada/downloads/UserGroups/eSUG-May2013/Eberhardt-PerlPPT.pdf"&gt;http://www.sas.com/offices/NA/canada/downloads/UserGroups/eSUG-May2013/Eberhardt-PerlPPT.pdf&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2013 15:58:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Retrieve-date-month-and-year-in-seperate-variables/m-p/134141#M36409</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-05-16T15:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve date month and year in seperate variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Retrieve-date-month-and-year-in-seperate-variables/m-p/134142#M36410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 11px; font-family: Arial, sans-serif; background-color: #d9d9d9;"&gt;Display the values in DDMONYYYY format. If there are ANS for date and month fields, display them as ANS/ANS/YYYY.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 11px; font-family: Arial, sans-serif; background-color: #d9d9d9;"&gt;This is my scenario. My date variable is stored as character and yyyy/mm/dd format. Can you help me? Let me know if you need more info&lt;/SPAN&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;You will probably need to run code to do this, rather than create a format.&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Let's assume your existing character variable is named DATE and the variable you want to create for your report is named DATE2.&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data want ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; if index(date,'ANS') then date2 = 'ANS/ANS/' || substr(date,1,4) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; else date2 = put( input( date, yymmdd10.), date9.) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 May 2013 17:13:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Retrieve-date-month-and-year-in-seperate-variables/m-p/134142#M36410</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-05-16T17:13:45Z</dc:date>
    </item>
  </channel>
</rss>

