<?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: Add hypen in month year dates (e.g. Jan-20) and another format to J 20 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Add-hypen-in-month-year-dates-e-g-Jan-20-and-another-format-to-J/m-p/779488#M248257</link>
    <description>&lt;P&gt;January June and July are going to be a pain. I'm assuming you actually want 21 though as your data is 2021? &lt;BR /&gt;Where are you planning to use these later? Picture formats are one option, a custom function is another or just a manual calculation in a data step. Each have their limitations though, so understanding how you use it later is important.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: in theory the picture format should work but doesn't for me for some reason. Maybe someone else can debug the format.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data report;
input date date9.;
format date date9.;
datalines; 
1JAN2021
2JAN2021
1FEB2021
;
run;

proc format;                                                         
   picture M_YY_FMT   (default=8)                                          
      low-high='%1b-%y'  (datatype=date)      
 ;                      
run;  

data want;
set report;
date_custom1 = catx("-", put(date, monname1.), put(date, year2.));
date_custom2 = put(date, m_yy_fmt.);
date2 = date;
format date2 m_yy_fmt.;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/323303"&gt;@ywon111&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, I have a large dataset that feeds into a monthly report. How do I format the dates so it has hyphen between month and year and also, simplify it to only show first letter (e.g. J 20, F 20, M 20, A 20, M 20, etc).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;E.g.&lt;/P&gt;
&lt;P&gt;data report;&lt;/P&gt;
&lt;P&gt;input date date9.;&lt;BR /&gt;format date date9.;&lt;BR /&gt;datalines; &lt;BR /&gt;1JAN2021&lt;BR /&gt;2JAN2021&lt;BR /&gt;1FEB2021&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Nov 2021 03:05:36 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-11-10T03:05:36Z</dc:date>
    <item>
      <title>Add hypen in month year dates (e.g. Jan-20) and another format to J 20</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-hypen-in-month-year-dates-e-g-Jan-20-and-another-format-to-J/m-p/779486#M248256</link>
      <description>&lt;P&gt;Hi, I have a large dataset that feeds into a monthly report. How do I format the dates so it has hyphen between month and year and also, simplify it to only show first letter (e.g. J 20, F 20, M 20, A 20, M 20, etc).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;E.g.&lt;/P&gt;
&lt;P&gt;data report;&lt;/P&gt;
&lt;P&gt;input date date9.;&lt;BR /&gt;format date date9.;&lt;BR /&gt;datalines; &lt;BR /&gt;1JAN2021&lt;BR /&gt;2JAN2021&lt;BR /&gt;1FEB2021&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 02:27:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-hypen-in-month-year-dates-e-g-Jan-20-and-another-format-to-J/m-p/779486#M248256</guid>
      <dc:creator>ywon111</dc:creator>
      <dc:date>2021-11-10T02:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Add hypen in month year dates (e.g. Jan-20) and another format to J 20</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-hypen-in-month-year-dates-e-g-Jan-20-and-another-format-to-J/m-p/779488#M248257</link>
      <description>&lt;P&gt;January June and July are going to be a pain. I'm assuming you actually want 21 though as your data is 2021? &lt;BR /&gt;Where are you planning to use these later? Picture formats are one option, a custom function is another or just a manual calculation in a data step. Each have their limitations though, so understanding how you use it later is important.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: in theory the picture format should work but doesn't for me for some reason. Maybe someone else can debug the format.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data report;
input date date9.;
format date date9.;
datalines; 
1JAN2021
2JAN2021
1FEB2021
;
run;

proc format;                                                         
   picture M_YY_FMT   (default=8)                                          
      low-high='%1b-%y'  (datatype=date)      
 ;                      
run;  

data want;
set report;
date_custom1 = catx("-", put(date, monname1.), put(date, year2.));
date_custom2 = put(date, m_yy_fmt.);
date2 = date;
format date2 m_yy_fmt.;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/323303"&gt;@ywon111&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, I have a large dataset that feeds into a monthly report. How do I format the dates so it has hyphen between month and year and also, simplify it to only show first letter (e.g. J 20, F 20, M 20, A 20, M 20, etc).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;E.g.&lt;/P&gt;
&lt;P&gt;data report;&lt;/P&gt;
&lt;P&gt;input date date9.;&lt;BR /&gt;format date date9.;&lt;BR /&gt;datalines; &lt;BR /&gt;1JAN2021&lt;BR /&gt;2JAN2021&lt;BR /&gt;1FEB2021&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 03:05:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-hypen-in-month-year-dates-e-g-Jan-20-and-another-format-to-J/m-p/779488#M248257</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-10T03:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: Add hypen in month year dates (e.g. Jan-20) and another format to J 20</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-hypen-in-month-year-dates-e-g-Jan-20-and-another-format-to-J/m-p/779595#M248320</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;January June and July are going to be a pain. I'm assuming you actually want 21 though as your data is 2021? &lt;BR /&gt;Where are you planning to use these later? Picture formats are one option, a custom function is another or just a manual calculation in a data step. Each have their limitations though, so understanding how you use it later is important.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: in theory the picture format should work but doesn't for me for some reason. Maybe someone else can debug the format.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data report;
input date date9.;
format date date9.;
datalines; 
1JAN2021
2JAN2021
1FEB2021
;
run;

proc format;                                                         
   picture M_YY_FMT   (default=8)                                          
      low-high='%1b-%y'  (datatype=date)      
 ;                      
run;  

data want;
set report;
date_custom1 = catx("-", put(date, monname1.), put(date, year2.));
date_custom2 = put(date, m_yy_fmt.);
date2 = date;
format date2 m_yy_fmt.;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/323303"&gt;@ywon111&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, I have a large dataset that feeds into a monthly report. How do I format the dates so it has hyphen between month and year and also, simplify it to only show first letter (e.g. J 20, F 20, M 20, A 20, M 20, etc).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;E.g.&lt;/P&gt;
&lt;P&gt;data report;&lt;/P&gt;
&lt;P&gt;input date date9.;&lt;BR /&gt;format date date9.;&lt;BR /&gt;datalines; &lt;BR /&gt;1JAN2021&lt;BR /&gt;2JAN2021&lt;BR /&gt;1FEB2021&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The M_YY_FMT format appears to work for me as written. The numeric value will right justify as default so may appear to have leading spaces in a table viewer. Changing the Default length to 4 "removes" the leading spaces for the example values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And agree that January, June and July as well as, March/ May and April/ August are extremely problematic for use with this display format.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 16:22:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-hypen-in-month-year-dates-e-g-Jan-20-and-another-format-to-J/m-p/779595#M248320</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-11-10T16:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: Add hypen in month year dates (e.g. Jan-20) and another format to J 20</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-hypen-in-month-year-dates-e-g-Jan-20-and-another-format-to-J/m-p/779598#M248323</link>
      <description>Good to know! I was using SAS On Demand and it didn't work there &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;</description>
      <pubDate>Wed, 10 Nov 2021 16:33:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-hypen-in-month-year-dates-e-g-Jan-20-and-another-format-to-J/m-p/779598#M248323</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-10T16:33:20Z</dc:date>
    </item>
  </channel>
</rss>

