<?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: Formatting dates similar to MMDDYY10., but with no leading zeros for single digit months and day in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/754419#M237908</link>
    <description>&lt;P&gt;My first response would be ask them not just why the zeros matters, but also why they would want to display dates in a style that will confuse half of their audience?&amp;nbsp; Is your second date supposed to be July fourth or the seventh of April?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CATX() is the function that concatenates with a delimiter.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length datestr $10;
datestr=catx('/',month(date),day(date),year(date));&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 15 Jul 2021 18:13:45 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-07-15T18:13:45Z</dc:date>
    <item>
      <title>Formatting dates similar to MMDDYY10., but with no leading zeros for single digit months and days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/754385#M237879</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have date fields in my output SAS dataset, which are formatted as MMDDYY10. (i.e., 07/15/2021).&amp;nbsp; I need to be able to find a way to do a final format of these fields to a date format similar to MMDDYY10., but with the leading zeros suppressed for one-digit months and one-digit days (i.e., 7/15/2021 and 7/4/2021).&amp;nbsp; I've looked at the COMPRESS function, and that doesn't seem to work.&amp;nbsp; I used the MONTH, DAY, and YEAR functions to isolate those components and tried to concatenate them together via CATX.&amp;nbsp; The result is a text version of the date, but if I go to convert that to a date format, I'll run into the same issue with MMDDYY10. as before.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to concatenate numbers with a delimiter, such as "/"?&amp;nbsp; Otherwise, is there a better alternative for solving the issue?&amp;nbsp; Please let me know.&amp;nbsp; Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 16:44:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/754385#M237879</guid>
      <dc:creator>lkujawa</dc:creator>
      <dc:date>2021-07-15T16:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting dates similar to MMDDYY10., but with no leading zeros for single digit months and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/754391#M237884</link>
      <description>&lt;P&gt;I think the best solution is to accept the leading zeros. It certainly is the easiest solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why do you want leading zeros removed?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 16:54:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/754391#M237884</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-15T16:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting dates similar to MMDDYY10., but with no leading zeros for single digit months and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/754392#M237885</link>
      <description>Look at a custom format, via Picture&lt;BR /&gt;&lt;A href="https://sasnrd.com/sas-date-datetime-proc-format-example/" target="_blank"&gt;https://sasnrd.com/sas-date-datetime-proc-format-example/&lt;/A&gt;.&lt;BR /&gt;&lt;BR /&gt;Note by default %d does not include the leading 0. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Jul 2021 16:55:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/754392#M237885</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-15T16:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting dates similar to MMDDYY10., but with no leading zeros for single digit months and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/754393#M237886</link>
      <description>&lt;P&gt;Roll your custom format with proc format&lt;/P&gt;
&lt;PRE&gt;proc format;
picture mydate (default=10)
low-high ='%m/%d/%Y' (datatype=date);
run;

data junk;
   x= '02Jul2021'd;
   put x mydate.;
run;&lt;/PRE&gt;
&lt;P&gt;The directives, those values with % such as %m %d %Y are case sensitive. Example using %M would mean "minutes" instead of month number, %y would mean year without the century (i.e. 2 digits). Also this is one place to use single quote ' instead of double quote " . With " the macro processor will think you are calling macros.&lt;/P&gt;
&lt;P&gt;The / are literal characters that appear in the value. Change to - if you want a dash or other separator character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Personally I would almost never use a format without the leading 0 as sort order of some output is going to look strange (October may come after January because 10 will come before 2/ for February)&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 16:55:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/754393#M237886</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-07-15T16:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting dates similar to MMDDYY10., but with no leading zeros for single digit months and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/754404#M237896</link>
      <description>&lt;P&gt;The data is going to a specific customer, and the customer specs are very rigid.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 17:15:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/754404#M237896</guid>
      <dc:creator>lkujawa</dc:creator>
      <dc:date>2021-07-15T17:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting dates similar to MMDDYY10., but with no leading zeros for single digit months and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/754408#M237900</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This looks very promising!&amp;nbsp; I will experiment with it and let you know how it works out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;lkujawa&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 17:18:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/754408#M237900</guid>
      <dc:creator>lkujawa</dc:creator>
      <dc:date>2021-07-15T17:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting dates similar to MMDDYY10., but with no leading zeros for single digit months and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/754419#M237908</link>
      <description>&lt;P&gt;My first response would be ask them not just why the zeros matters, but also why they would want to display dates in a style that will confuse half of their audience?&amp;nbsp; Is your second date supposed to be July fourth or the seventh of April?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CATX() is the function that concatenates with a delimiter.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length datestr $10;
datestr=catx('/',month(date),day(date),year(date));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Jul 2021 18:13:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/754419#M237908</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-15T18:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting dates similar to MMDDYY10., but with no leading zeros for single digit months and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/755116#M238230</link>
      <description>&lt;P&gt;I've been testing the logic, and the picture format as mentioned in both your reply and Reeza's works.&amp;nbsp; I have one issue though.&amp;nbsp; When I apply the PROC REPORT against the existing dataset, I get the date in the correct format and it can be right-aligned, but I still need the data to be in a raw dataset, not a formatted report.&amp;nbsp; If I use your logic in the DATA step and try to put that format against one of the existing date fields, it will put the data in a left-aligned character format.&amp;nbsp; Is there a way to resolve this?&amp;nbsp; Please advise.&amp;nbsp; Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jul 2021 20:10:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/755116#M238230</guid>
      <dc:creator>lkujawa</dc:creator>
      <dc:date>2021-07-19T20:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting dates similar to MMDDYY10., but with no leading zeros for single digit months and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/755132#M238237</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/327431"&gt;@lkujawa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I've been testing the logic, and the picture format as mentioned in both your reply and Reeza's works.&amp;nbsp; I have one issue though.&amp;nbsp; When I apply the PROC REPORT against the existing dataset, I get the date in the correct format and it can be right-aligned, but I still need the data to be in a raw dataset, not a formatted report.&amp;nbsp; If I use your logic in the DATA step and try to put that format against one of the existing date fields, it will put the data in a left-aligned character format.&amp;nbsp; Is there a way to resolve this?&amp;nbsp; Please advise.&amp;nbsp; Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I cannot figure out what you mean.&amp;nbsp; &amp;nbsp;What is a "raw dataset"?&amp;nbsp; Do you mean a SAS dataset?&amp;nbsp; SAS only has two data types, fixed length character strings and floating point numbers.&amp;nbsp; So your choices are a numeric date field with custom format for display or a character variable.&amp;nbsp; You could produce the values in the character field as right aligned within the 10 bytes needed to hold any possible valid date.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jul 2021 20:55:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/755132#M238237</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-19T20:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting dates similar to MMDDYY10., but with no leading zeros for single digit months and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/755422#M238395</link>
      <description>&lt;P&gt;I do mean a SAS dataset.&amp;nbsp; I know that using PROC REPORT along with picture can produce the date in the right format without the leading zeros for month and day and also right-aligned, but can that then be translated back to the actual SAS dataset in a numeric date format?&amp;nbsp; I know that one of the contributors posted sample logic using picture and a SAS dataset.&amp;nbsp; However, in that logic, the sample dataset had hard-coded date information.&amp;nbsp; I have a SAS dataset that already has a date formatted as DATE9.&amp;nbsp; If I try to use the picture logic to create a new user-defined format and then try to apply it to the already-formatted date, it doesn't seem to work.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 17:27:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-dates-similar-to-MMDDYY10-but-with-no-leading-zeros/m-p/755422#M238395</guid>
      <dc:creator>lkujawa</dc:creator>
      <dc:date>2021-07-20T17:27:29Z</dc:date>
    </item>
  </channel>
</rss>

