<?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: date format mm-dd in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/721055#M223406</link>
    <description>Sorry it posted before I finished typing&lt;BR /&gt;I change the order to MMDDY5.&lt;BR /&gt;Which give me reverse 05/26</description>
    <pubDate>Mon, 22 Feb 2021 20:39:15 GMT</pubDate>
    <dc:creator>vhickin64</dc:creator>
    <dc:date>2021-02-22T20:39:15Z</dc:date>
    <item>
      <title>date format mm-dd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/31434#M6022</link>
      <description>Is there a date format that creates mm-dd or mm/dd or mmmdd?&lt;BR /&gt;
For example, 09-10 or 09/10 or Sep10.&lt;BR /&gt;
Basically I would like to create a date without a year.&lt;BR /&gt;
Thank you.</description>
      <pubDate>Wed, 10 Nov 2010 08:03:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/31434#M6022</guid>
      <dc:creator>gzr2mz39</dc:creator>
      <dc:date>2010-11-10T08:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: date format mm-dd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/31435#M6023</link>
      <description>you could read through the manual, or on-line doc at the formats by category at &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a001263753.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a001263753.htm&lt;/A&gt; where date and time formats are documented together&lt;BR /&gt;
 &lt;BR /&gt;
 &lt;B&gt; but we have the SAS System,  so why not use it to search for you !?&lt;/B&gt;&lt;BR /&gt;
  &lt;BR /&gt;
(in)format hunter&lt;BR /&gt;
as posted here and on SAS-L&lt;BR /&gt;
adapted for a "time" format search[pre]*********************************************************&lt;BR /&gt;
* format hunter                                         *&lt;BR /&gt;
********************************************************;&lt;BR /&gt;
%let have_time= 23:15:00 ; &lt;BR /&gt;
%let required = 23:15    ;&lt;BR /&gt;
&lt;BR /&gt;
data test ;&lt;BR /&gt;
  set  sashelp.vformat ; *listed in this data set, are all formats and in formats;&lt;BR /&gt;
  where fmttype='F' ;  *want just formats;&lt;BR /&gt;
  where also fmtname ne:'$' ; * and not character formats;&lt;BR /&gt;
  length str $40 ;&lt;B&gt;&lt;BR /&gt;
  str = putn( "&amp;amp;have_time"t,  fmtname ); &lt;/B&gt;&lt;BR /&gt;
  if not _error_ ;&lt;BR /&gt;
  if left(str) = "&amp;amp;required" ; &lt;BR /&gt;
  put fmtname= str= ;&lt;BR /&gt;
  option  errors = 0;&lt;BR /&gt;
run;[/pre]in my log the results presented (among other lines) were&lt;BR /&gt;
&lt;BR /&gt;
NOTE: Limit set by ERRORS= option reached.  Further errors of this type will not be printed.&lt;BR /&gt;
fmtname=HHMM str=23:15&lt;BR /&gt;
NOTE: There were 589 observations read from the data set SASHELP.VFORMAT.&lt;BR /&gt;
 &lt;BR /&gt;
The search reveals &lt;BR /&gt;
fmtname=HHMM str=23:15&lt;BR /&gt;
So try format  HHMM.&lt;BR /&gt;
 &lt;BR /&gt;
It took very little time to adapt and run the "format hunter"&lt;BR /&gt;
 &lt;BR /&gt;
no need to worry about that "NOTE: Limit set by ERRORS= " (this time)</description>
      <pubDate>Wed, 10 Nov 2010 08:46:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/31435#M6023</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-11-10T08:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: date format mm-dd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/31436#M6024</link>
      <description>Hi.&lt;BR /&gt;
I try many times ,Finally got it.&lt;BR /&gt;
I really  think it is no easy to achieve.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data _null_;&lt;BR /&gt;
 x=put('10aug2009'd,mmddyy5.);&lt;BR /&gt;
 put 'NOTE:' x=;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
and&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data _null_;&lt;BR /&gt;
 x=put('10aug2009'd,mmddyyd5.);&lt;BR /&gt;
 put 'NOTE:' x=;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Ksharp

Message was edited by: Ksharp</description>
      <pubDate>Thu, 11 Nov 2010 08:47:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/31436#M6024</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2010-11-11T08:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: date format mm-dd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/31437#M6025</link>
      <description>&amp;gt; Hi.&lt;BR /&gt;
&amp;gt; I try many times ,Finally got it.&lt;BR /&gt;
&amp;gt; I really  think it is no easy to achieve.&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; Message was edited by: Ksharp&lt;BR /&gt;
&lt;BR /&gt;
are you able to offer a log showing what was 'no easy' ?&lt;BR /&gt;
&lt;BR /&gt;
Seeking a format to provide the HH and MM, &lt;BR /&gt;
I thought checking first for a format named HHMM would be really easy!</description>
      <pubDate>Thu, 11 Nov 2010 08:54:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/31437#M6025</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-11-11T08:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: date format mm-dd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/31438#M6026</link>
      <description>Thank you.</description>
      <pubDate>Thu, 11 Nov 2010 18:00:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/31438#M6026</guid>
      <dc:creator>gzr2mz39</dc:creator>
      <dc:date>2010-11-11T18:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: date format mm-dd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/31439#M6027</link>
      <description>The DATE5. format will give a similar result.  More on date formats can be found in Derek Morgan's book "The Essential Guide to SAS Dates and Times" &lt;A href="https://support.sas.com/pubscat/bookdetails.jsp?pc=59411" target="_blank"&gt;https://support.sas.com/pubscat/bookdetails.jsp?pc=59411&lt;/A&gt;</description>
      <pubDate>Thu, 11 Nov 2010 19:53:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/31439#M6027</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2010-11-11T19:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: date format mm-dd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/31440#M6028</link>
      <description>Hi.Peter.&lt;BR /&gt;
I try your code.But it does not find anything.&lt;BR /&gt;
'not easy' means I try many times and look up the SAS documentation all over.&lt;BR /&gt;
I also think your code is right. Maybe does not suit this situation.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Regards.&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Fri, 12 Nov 2010 02:38:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/31440#M6028</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2010-11-12T02:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: date format mm-dd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/31441#M6029</link>
      <description>Hi.Art Carpenter.&lt;BR /&gt;
I have read several books you write, they are pretty good, and learned a lot from them.&lt;BR /&gt;
&lt;BR /&gt;
Regards.&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Fri, 12 Nov 2010 02:42:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/31441#M6029</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2010-11-12T02:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: date format mm-dd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/31442#M6030</link>
      <description>Ksharp&lt;BR /&gt;
thank you&lt;BR /&gt;
your experience and the posting from ArtC have sent me back to reviewing and improve my "format hunter"&lt;BR /&gt;
Not yet a macro,( I modify the basic data step each time I'm hunting), the hunter now tries twice and reveals more that one result (at last)[pre]%let required = 23/12    ;&lt;BR /&gt;
%let have_    = 23Dec2010;&lt;BR /&gt;
 &lt;BR /&gt;
data date_format_hunter_found( keep= fmtname  str  );&lt;BR /&gt;
  set  sashelp.vformat ;&lt;BR /&gt;
  where fmttype='F' ;  *just formats;&lt;BR /&gt;
  where also fmtname ne:'$' ; * and not character formats;&lt;BR /&gt;
  retain width %sysfunc( length( %superq(required)) ) ;&lt;BR /&gt;
 &lt;BR /&gt;
  str = putn( "&amp;amp;have_"d, fmtname ) ; *default format width ;&lt;BR /&gt;
 &lt;BR /&gt;
  if left(str) NE "&amp;amp;required"&lt;BR /&gt;
      and not _error_&lt;BR /&gt;
      and minw LE width LE maxw&lt;BR /&gt;
  then&lt;BR /&gt;
        str = putn( "&amp;amp;have_"d, fmtname, width );&lt;BR /&gt;
                      * using requested width ;&lt;BR /&gt;
 &lt;BR /&gt;
  if _error_ then put 'NOTE- ' fmtname=   ;&lt;BR /&gt;
  _error_=0 ;&lt;BR /&gt;
  if left(str) NE "&amp;amp;required" then delete ;&lt;BR /&gt;
 &lt;BR /&gt;
 * report on successes ;&lt;BR /&gt;
  put "&amp;amp;have_ &amp;amp;required " fmtname= str= width= ;&lt;BR /&gt;
run;[/pre]This version finds formats for dd/mm  as follows[pre]23Dec2010 23/12 fmtname=CATDFDD str=23/12 width=5&lt;BR /&gt;
23Dec2010 23/12 fmtname=CSYDFDD str=23/12 width=5&lt;BR /&gt;
23Dec2010 23/12 fmtname=DDMMYY str=23/12 width=5&lt;BR /&gt;
23Dec2010 23/12 fmtname=DDMMYYS str=23/12 width=5&lt;BR /&gt;
23Dec2010 23/12 fmtname=FRADFDD str=23/12 width=5&lt;BR /&gt;
NOTE: Argument 2 to function PUTN at line 1256 column 9 is invalid.&lt;BR /&gt;
      fmtname=FREE&lt;BR /&gt;
23Dec2010 23/12 fmtname=FRSDFDD str=23/12 width=5&lt;BR /&gt;
23Dec2010 23/12 fmtname=ITADFDD str=23/12 width=5&lt;BR /&gt;
23Dec2010 23/12 fmtname=PTGDFDD str=23/12 width=5&lt;BR /&gt;
NOTE: There were 589 observations read  [/pre]&lt;BR /&gt;
For  dd-mm layout  formats found were[pre]23Dec2010 23-12 fmtname=DDMMYYD str=23-12 width=5&lt;BR /&gt;
NOTE: Argument 2 to function PUTN at line 1281 column 9 is invalid.&lt;BR /&gt;
      fmtname=FREE&lt;BR /&gt;
23Dec2010 23-12 fmtname=NLDDFDD str=23-12 width=5&lt;BR /&gt;
23Dec2010 23-12 fmtname=POLDFDD str=23-12 width=5[/pre] and for mm-dd only one format was revealed[pre]23Dec2010 12-23 fmtname=MMDDYYD str=12-23 width=5[/pre]&lt;BR /&gt;
Of course, you might prefer to create your own format with PROC FORMAT and the PICTURE statement "directives" documented at &lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473467.htm#a000530223" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473467.htm#a000530223&lt;/A&gt;  and since the online-doc examples of the PICTURE statement don't demonstrate these date directives, here is one: &lt;BR /&gt;
proc format ; &lt;BR /&gt;
picture ksharp_date other = '%d-%m'( datatype= date ) ;&lt;BR /&gt;
run;&lt;BR /&gt;
%put demo %sysfunc( today(), ksharp_date. ) ;&lt;BR /&gt;
which produced the "demo"[pre]1325  %put demo %sysfunc( today(), ksharp_date. ) ;&lt;BR /&gt;
demo 13-11[/pre]</description>
      <pubDate>Sat, 13 Nov 2010 16:41:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/31442#M6030</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-11-13T16:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: date format mm-dd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/31443#M6031</link>
      <description>Peter.&lt;BR /&gt;
I really adore your spirit of discovery. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Best Regards.&lt;BR /&gt;
Ksharp</description>
      <pubDate>Mon, 15 Nov 2010 03:15:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/31443#M6031</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2010-11-15T03:15:42Z</dc:date>
    </item>
    <item>
      <title>Re: date format mm-dd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/393977#M94903</link>
      <description>&lt;P&gt;It's been a few years since the question was first aske. But using SAS 9.4 , this is fairly simple.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA DATE4;
FORMAT	DT 		mmddyy10. 
		N4 		mmddyyN4.
		D5 		mmddyyD5.
		S5 		mmddyyS5.
		P5 		mmddyyP5.
		DATE5	DATE5.;
DT=TODAY();
N4=DT;
D5=DT;
S5=DT;
P5=DT;
DATE5=DT;
	PUT DT=;
	PUT N4=;
	PUT S5=;
	PUT P5=;
	PUT DATE5=;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That code produces this output in the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DT=09/07/2017
N4=0907
S5=09/07
P5=09.07
DATE5=07SEP
NOTE: The data set WORK.DATE4 has 1 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could do the same thing with PUT Statements, if you want the values to show up in a character vs. date format.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 17:51:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/393977#M94903</guid>
      <dc:creator>jcfinck</dc:creator>
      <dc:date>2017-09-07T17:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: date format mm-dd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/721051#M223403</link>
      <description>I highly recommend this book - The most used of all my SAS books.&lt;BR /&gt;Morgan's book "The Essential Guide to SAS Dates and Times"&lt;BR /&gt;It shows on page 21&lt;BR /&gt;Format Name Result Comment&lt;BR /&gt;DDMMYY5. 26/05&lt;BR /&gt;DDMMYY6. 260502&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;MMDDYY5.</description>
      <pubDate>Mon, 22 Feb 2021 20:36:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/721051#M223403</guid>
      <dc:creator>vhickin64</dc:creator>
      <dc:date>2021-02-22T20:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: date format mm-dd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/721055#M223406</link>
      <description>Sorry it posted before I finished typing&lt;BR /&gt;I change the order to MMDDY5.&lt;BR /&gt;Which give me reverse 05/26</description>
      <pubDate>Mon, 22 Feb 2021 20:39:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format-mm-dd/m-p/721055#M223406</guid>
      <dc:creator>vhickin64</dc:creator>
      <dc:date>2021-02-22T20:39:15Z</dc:date>
    </item>
  </channel>
</rss>

