<?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: DatePart in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/DatePart/m-p/487223#M31535</link>
    <description>&lt;P&gt;Congratulations! I believe this is a first. You actually solved your problem in your own query!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The&amp;nbsp;DATEPART function:&amp;nbsp;Extracts the date from a SAS datetime value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
    <pubDate>Wed, 15 Aug 2018 22:45:54 GMT</pubDate>
    <dc:creator>TomKari</dc:creator>
    <dc:date>2018-08-15T22:45:54Z</dc:date>
    <item>
      <title>DatePart</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/DatePart/m-p/487218#M31533</link>
      <description>&lt;P&gt;Did some looking around and did not see anything on this, building an expression in EG 7.1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Trying to figure out how to create a new MonthYr date value variable from a time date a stamp.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MDY(MONTH(date_variable),1,YEAR(date_variable)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have used the above code in the past when it is a&amp;nbsp;mm/dd/yy stamp, the time part is throwing me off, how do I build in the DatePart?&amp;nbsp; I could do it in 2 steps but I'm sure there is a way to make it 1&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 22:16:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/DatePart/m-p/487218#M31533</guid>
      <dc:creator>RickyS</dc:creator>
      <dc:date>2018-08-15T22:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: DatePart</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/DatePart/m-p/487221#M31534</link>
      <description>&lt;P&gt;Use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;datepart(intnx("DTMONTH", date_variable, 0))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 22:44:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/DatePart/m-p/487221#M31534</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-08-15T22:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: DatePart</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/DatePart/m-p/487223#M31535</link>
      <description>&lt;P&gt;Congratulations! I believe this is a first. You actually solved your problem in your own query!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The&amp;nbsp;DATEPART function:&amp;nbsp;Extracts the date from a SAS datetime value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 22:45:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/DatePart/m-p/487223#M31535</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2018-08-15T22:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: DatePart</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/DatePart/m-p/487229#M31536</link>
      <description>&lt;P&gt;And I bet I can make a custom format that works directly with a datetime variable so that for many purposes no new variable is needed at all.&lt;/P&gt;
&lt;P&gt;But I am not sure what your desired "monthyr" would look like.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 23:48:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/DatePart/m-p/487229#M31536</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-15T23:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: DatePart</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/DatePart/m-p/487361#M31538</link>
      <description>&lt;P&gt;Perhaps I'm missing something&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Create_MonthYr */&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;(DATEPART(t1.created_at)) FORMAT=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;MONYY7.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; LABEL=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"Create_MonthYr"&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AS&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Create_MonthYr,&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;This gives me a JAN2018 format but it still&amp;nbsp;has a SAS value associated with multiple days 01/01/2018, 01/02/2018, 01/03/2018&amp;nbsp;etc. this makes it more difficult&amp;nbsp;to do some basic reporting like aggregating transaction counts by monthyr across other variables. &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;Creating&amp;nbsp;a common month year SAS date value&amp;nbsp;will enable this aggregation.&amp;nbsp;I've done this before with MDY function when it is a&amp;nbsp;date, looking for a solution for time date &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 12:03:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/DatePart/m-p/487361#M31538</guid>
      <dc:creator>RickyS</dc:creator>
      <dc:date>2018-08-16T12:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: DatePart</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/DatePart/m-p/487490#M31544</link>
      <description>&lt;P&gt;Did it as 2 steps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATEPART(t1.date)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MDY(month(t1.date),1,year(t1.date))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this converts everything to 1st date of each month&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 16:03:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/DatePart/m-p/487490#M31544</guid>
      <dc:creator>RickyS</dc:creator>
      <dc:date>2018-08-16T16:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: DatePart</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/DatePart/m-p/487574#M31546</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67527"&gt;@RickyS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Perhaps I'm missing something&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* Create_MonthYr */&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;(DATEPART(t1.created_at)) FORMAT=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;MONYY7.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; LABEL=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"Create_MonthYr"&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AS&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Create_MonthYr,&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;This gives me a JAN2018 format but it still&amp;nbsp;has a SAS value associated with multiple days 01/01/2018, 01/02/2018, 01/03/2018&amp;nbsp;etc. this makes it more difficult&amp;nbsp;to do some basic reporting like aggregating transaction counts by monthyr across other variables. &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;Creating&amp;nbsp;a common month year SAS date value&amp;nbsp;will enable this aggregation.&amp;nbsp;I've done this before with MDY function when it is a&amp;nbsp;date, looking for a solution for time date &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think you need to explain what the difficulty is with your aggregating. Almost every procedure will create groups based on the formatted value of a variable as defined in the proc.&lt;/P&gt;
&lt;P&gt;SAS may not supply the exact datetime format you want but proc format with a Picture format will allow a great deal of customization.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data junk;
   do date='03OCT2017:01:23:27'dt to '15JAN2018:18:24:16'dt by 1385;
      value = rand('uniform');
      output;
   end;
run;
proc format library=work;
picture dtmonyr (default=7)
low-high='%b%Y' (datatype=datetime)
;
run;
proc means data=junk  mean max std;
   class date;
   format date dtmonyr.;
   var value ;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Aug 2018 20:12:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/DatePart/m-p/487574#M31546</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-16T20:12:19Z</dc:date>
    </item>
  </channel>
</rss>

