<?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 Date output to Month and Year in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-output-to-Month-and-Year/m-p/348586#M80730</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get a dataset from a Sharepoint list and the date value is date and time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use the below to convert to a yymmdd and format as mmmyy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DefinedPeriod=INPUT(PUT(Date ,8.),YYMMDD8.);format DefinedPeriod monyy7.;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However I need to count the number of defined periods ( number of months from the dates entered)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eaxample of Date entries are: 01/03/2017, 02/03/2017,01/04/2017, 02/04/2017.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code below gives me a count of DefinedPeriodA of 4 when I want it to be 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;by DefinedPeriod;if first. DefinedPeriod then DefinedPeriodA= 1;&lt;/PRE&gt;</description>
    <pubDate>Mon, 10 Apr 2017 04:30:05 GMT</pubDate>
    <dc:creator>Haydn</dc:creator>
    <dc:date>2017-04-10T04:30:05Z</dc:date>
    <item>
      <title>Date output to Month and Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-output-to-Month-and-Year/m-p/348586#M80730</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get a dataset from a Sharepoint list and the date value is date and time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use the below to convert to a yymmdd and format as mmmyy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DefinedPeriod=INPUT(PUT(Date ,8.),YYMMDD8.);format DefinedPeriod monyy7.;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However I need to count the number of defined periods ( number of months from the dates entered)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eaxample of Date entries are: 01/03/2017, 02/03/2017,01/04/2017, 02/04/2017.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code below gives me a count of DefinedPeriodA of 4 when I want it to be 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;by DefinedPeriod;if first. DefinedPeriod then DefinedPeriodA= 1;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Apr 2017 04:30:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-output-to-Month-and-Year/m-p/348586#M80730</guid>
      <dc:creator>Haydn</dc:creator>
      <dc:date>2017-04-10T04:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Date output to Month and Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-output-to-Month-and-Year/m-p/348595#M80736</link>
      <description>&lt;P&gt;Assigning a month format doesn't change the stored values of your date variable that is they still remain as date values displaying with your month format. I would suggest to extract month values using month function and the group by month so that you would get your desired result:&lt;/P&gt;&lt;P&gt;/*sample*/&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input defined_period ddmmyy10.;&lt;BR /&gt;format defined_period ddmmyy10.;&lt;BR /&gt;month=month(defined_period);&lt;BR /&gt;datalines;&lt;BR /&gt;01/03/2017&lt;BR /&gt;02/03/2017&lt;BR /&gt;01/04/2017&lt;BR /&gt;02/04/2017&lt;BR /&gt;;&lt;BR /&gt;proc sort data=have;&lt;BR /&gt;by month;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;by month;&lt;BR /&gt;if first.month then count=0;&lt;BR /&gt;count+1;&lt;BR /&gt;if last.month;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naveen Srinivasan&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 05:53:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-output-to-Month-and-Year/m-p/348595#M80736</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-04-10T05:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: Date output to Month and Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-output-to-Month-and-Year/m-p/348596#M80737</link>
      <description>data have;&lt;BR /&gt;input defined_period DDMMYY10.;&lt;BR /&gt;datalines;&lt;BR /&gt;01/03/2017&lt;BR /&gt;02/03/2017&lt;BR /&gt;01/04/2017&lt;BR /&gt;02/04/2017&lt;BR /&gt;03/04/2017&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc print;run;&lt;BR /&gt;data have;&lt;BR /&gt;set have;&lt;BR /&gt;format defined_period DDMMYY10.;&lt;BR /&gt;month=month(defined_period);&lt;BR /&gt;run;&lt;BR /&gt;proc sql;&lt;BR /&gt;select month,count(*) as total from have group by month;&lt;BR /&gt;quit;</description>
      <pubDate>Mon, 10 Apr 2017 06:04:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-output-to-Month-and-Year/m-p/348596#M80737</guid>
      <dc:creator>lakshmi_74</dc:creator>
      <dc:date>2017-04-10T06:04:30Z</dc:date>
    </item>
  </channel>
</rss>

