<?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: MDY Function in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/413802#M26606</link>
    <description>&lt;P&gt;Ah I did see that post but forgot to include my other question. Whoops!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to use both datepart and mdy in the same statement? I.e. creating a computed column?&lt;/P&gt;</description>
    <pubDate>Wed, 15 Nov 2017 21:13:23 GMT</pubDate>
    <dc:creator>mmagnuson</dc:creator>
    <dc:date>2017-11-15T21:13:23Z</dc:date>
    <item>
      <title>MDY Function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/413792#M26602</link>
      <description>&lt;P&gt;I have a variable date1 which shows, for example, 01JAN2010 00:00:00 and want it to show up (1/1/10)&lt;/P&gt;&lt;P&gt;Do I do MDY(date1, 1, date1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I get it so that I can use the variable to populate to that format?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 20:57:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/413792#M26602</guid>
      <dc:creator>mmagnuson</dc:creator>
      <dc:date>2017-11-15T20:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: MDY Function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/413799#M26605</link>
      <description>&lt;P&gt;That's a DATETIME not DATE field. First use DATEPART to get the date portion and then apply your functions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any relation to the almost identical post here?&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Enterprise-Guide/Query-filter-WEEK-and-similar-date-time-functions-do-not-work/m-p/413793" target="_blank"&gt;https://communities.sas.com/t5/SAS-Enterprise-Guide/Query-filter-WEEK-and-similar-date-time-functions-do-not-work/m-p/413793&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 21:09:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/413799#M26605</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-15T21:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: MDY Function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/413802#M26606</link>
      <description>&lt;P&gt;Ah I did see that post but forgot to include my other question. Whoops!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to use both datepart and mdy in the same statement? I.e. creating a computed column?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 21:13:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/413802#M26606</guid>
      <dc:creator>mmagnuson</dc:creator>
      <dc:date>2017-11-15T21:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: MDY Function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/413806#M26608</link>
      <description>&lt;P&gt;Changing the form&amp;nbsp; in which a variable prints requires a format, not a function.&amp;nbsp; So convert from a datetime to a date:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;var = datepart(var);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then apply a format:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;format var mmddyys10.;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 21:20:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/413806#M26608</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-15T21:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: MDY Function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/413808#M26610</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/142148"&gt;@mmagnuson&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Ah I did see that post but forgot to include my other question. Whoops!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it possible to use both datepart and mdy in the same statement? I.e. creating a computed column?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, you can nest functions in SAS (and most other languages).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 21:23:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/413808#M26610</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-15T21:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: MDY Function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/413819#M26612</link>
      <description>&lt;P&gt;Looking at what you're actually asking though, you don't need to do any of that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to either :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;1. Create a date variable and apply the correct format&lt;/P&gt;
&lt;P&gt;2. Apply the appropriate format to the datetime variable if you don't care about the time, ie dtmmddyy10. (check docs for exact, this is just a guess)&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 21:53:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/413819#M26612</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-15T21:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: MDY Function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/413827#M26613</link>
      <description>&lt;P&gt;The MDY() function is for converting three numbers, month, day and year, into a date.&lt;/P&gt;
&lt;P&gt;Your example value is a datetime value.&amp;nbsp; You can just use the DATEPART() function to convert it to a date value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How you display it depends on the format you attach to the variable.&amp;nbsp; It seems that currently you have the DATETIME format attached, which is a good format for a datetime value.&amp;nbsp;There are formats that can display a datetime value in Y,M,D order if you want, but I don't think there are any that can do it in M,D,Y order.&amp;nbsp; But you could build you own using PROC FORMAT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you could convert your datetime to a date, then there are many more choices for formats you can use to display the data. MMDDYY or DDMMYY or YYMMDD or DATE etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 22:21:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/413827#M26613</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-15T22:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: MDY Function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/414000#M26625</link>
      <description>&lt;P&gt;I also then want the date1 to be ("month of date1' , 1, 'year of date1')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I make a computed column and datepart(date1) then use that in the MDY function: MDY((datepart(date1), 1, (datepartdate1)) then it doesn't work&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 13:57:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/414000#M26625</guid>
      <dc:creator>mmagnuson</dc:creator>
      <dc:date>2017-11-16T13:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: MDY Function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/414028#M26626</link>
      <description>&lt;P&gt;You need to give the MDY() values of month and year values, not dates.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;old_dt = '05NOV2017:00:00'dt ;
new_date = mdy(month(datepart(old_dt)),1,year(datepart(old_dt)));
format new_date date9.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can also use the INTNX() function to move dates by intervals.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
old_dt = '05NOV2017:00:00'dt ;
format old_dt new_dt datetime20. new_date date9.;

new_date = mdy(month(datepart(old_dt)),1,year(datepart(old_dt)));
put (_all_) (=);

new_date=intnx('month',datepart(old_dt),0,'b');
put (_all_) (=);

new_dt = intnx('dtmonth',old_dt,0,'b');
new_date=datepart(new_dt);
put (_all_) (=);

run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;old_dt=05NOV2017:00:00:00 new_dt=. new_date=01NOV2017
old_dt=05NOV2017:00:00:00 new_dt=. new_date=01NOV2017
old_dt=05NOV2017:00:00:00 new_dt=01NOV2017:00:00:00 new_date=01NOV2017&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Nov 2017 15:06:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/414028#M26626</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-16T15:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: MDY Function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/414054#M26628</link>
      <description>&lt;P&gt;Use INTNX to move the date to the beginning of the month, not MDY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;INTNX('month', date1, 0, 'b')&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Nov 2017 15:50:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/MDY-Function/m-p/414054#M26628</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-16T15:50:58Z</dc:date>
    </item>
  </channel>
</rss>

