<?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 Converting concat char to concat date using monyy5. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Converting-concat-char-to-concat-date-using-monyy5/m-p/236633#M55261</link>
    <description>&lt;P&gt;I have a field called reporting_dt_bin shown as a character. It is a concatenate of reporting_Yr and reporting month, both of which were originally dates&lt;/P&gt;
&lt;P&gt;Reporting_dt_Bin = (Reporting_year_Bin || '-' || Reporting_month_txt); produces this output example&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="116"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="116"&gt;
&lt;P&gt;Reporting_dt_Bin&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="116"&gt;
&lt;P&gt;15- 3&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="116"&gt;
&lt;P&gt;15- 4&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="116"&gt;
&lt;P&gt;15- 5&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="116"&gt;
&lt;P&gt;15- 6&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="116"&gt;
&lt;P&gt;15- 7&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to maintain the reporting_dt_bin format and create another format that converts this into a date&lt;/P&gt;
&lt;P&gt;Example&lt;/P&gt;
&lt;P&gt;Reporting_dt_bin2&lt;/P&gt;
&lt;P&gt;Mar15&lt;/P&gt;
&lt;P&gt;Apr15&lt;/P&gt;
&lt;P&gt;May15&lt;/P&gt;
&lt;P&gt;The date format would be monyy5.&lt;/P&gt;</description>
    <pubDate>Thu, 26 Nov 2015 17:17:54 GMT</pubDate>
    <dc:creator>Q1983</dc:creator>
    <dc:date>2015-11-26T17:17:54Z</dc:date>
    <item>
      <title>Converting concat char to concat date using monyy5.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Converting-concat-char-to-concat-date-using-monyy5/m-p/236633#M55261</link>
      <description>&lt;P&gt;I have a field called reporting_dt_bin shown as a character. It is a concatenate of reporting_Yr and reporting month, both of which were originally dates&lt;/P&gt;
&lt;P&gt;Reporting_dt_Bin = (Reporting_year_Bin || '-' || Reporting_month_txt); produces this output example&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="116"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="116"&gt;
&lt;P&gt;Reporting_dt_Bin&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="116"&gt;
&lt;P&gt;15- 3&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="116"&gt;
&lt;P&gt;15- 4&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="116"&gt;
&lt;P&gt;15- 5&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="116"&gt;
&lt;P&gt;15- 6&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="116"&gt;
&lt;P&gt;15- 7&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to maintain the reporting_dt_bin format and create another format that converts this into a date&lt;/P&gt;
&lt;P&gt;Example&lt;/P&gt;
&lt;P&gt;Reporting_dt_bin2&lt;/P&gt;
&lt;P&gt;Mar15&lt;/P&gt;
&lt;P&gt;Apr15&lt;/P&gt;
&lt;P&gt;May15&lt;/P&gt;
&lt;P&gt;The date format would be monyy5.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 17:17:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Converting-concat-char-to-concat-date-using-monyy5/m-p/236633#M55261</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2015-11-26T17:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: Converting concat char to concat date using monyy5.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Converting-concat-char-to-concat-date-using-monyy5/m-p/236646#M55262</link>
      <description>&lt;P&gt;There may be more elegant solutions, but this should do what you want, if the year and month variables are still available:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length Reporting_dt_bin $5;
Reporting_year_Bin='15';
do m=3 to 7;
  Reporting_month_txt=put(m,2.);
  Reporting_dt_Bin = (Reporting_year_Bin || '-' || Reporting_month_txt);
  output;
end;
drop m;
run;

proc print width=min;
run;


data want;
set have;
length Reporting_dt_bin2 $5;
Reporting_dt_bin2=propcase(put(input(cats(Reporting_year_Bin,put(input(Reporting_month_txt,2.),z2.)), yymmn4.),monyy5.));
run;

proc print width=min;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If only&amp;nbsp;&lt;SPAN&gt;Reporting_dt_Bin is available, you could resort to this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length Reporting_dt_bin $5;
do m=3 to 7;
  Reporting_dt_bin='15-'||put(m,2.);
  output;
end;
drop m;
run;

proc print width=min;
run;


data want;
set have;
length Reporting_dt_bin2 $5;
Reporting_dt_bin2=propcase(put(input(cats(scan(Reporting_dt_bin,1,'-'),put(input(scan(Reporting_dt_bin,2,'-'),2.),z2.)), yymmn4.),monyy5.));
run;

proc print width=min;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;If you are happy with MAR15 etc. (this is actually MONYY5. format) instead of Mar15, you can omit PROPCASE.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 18:14:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Converting-concat-char-to-concat-date-using-monyy5/m-p/236646#M55262</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2015-11-26T18:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: Converting concat char to concat date using monyy5.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Converting-concat-char-to-concat-date-using-monyy5/m-p/236731#M55267</link>
      <description>&lt;P&gt;Here is another solution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;infile cards dsd;&lt;BR /&gt;input Reporting_dt_Bin$;&lt;BR /&gt;cards;&lt;BR /&gt;15- 3&lt;BR /&gt;15- 4&lt;BR /&gt;15- 5&lt;BR /&gt;15- 6&lt;BR /&gt;15- 7&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;proc format;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;value mon 1 = JAN&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2 = FEB&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 3 = MAR&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 4 = APR&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 5 = MAY&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 6 = JUN&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 7 = JUL&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 8 = AUG&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 9 = SEP&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 10= OCT&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 11= NOV&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 12= DEC&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;Reporting_dt_Bin2 = input(cats(scan(Reporting_dt_Bin,1,'-'),put(input(scan(Reporting_dt_Bin,2,'-'),8.),mon.),input(put(year(today()),4.),$4.)),date9.);&lt;BR /&gt;format Reporting_dt_Bin2 monyy5.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This takes the character input you have, breaks it up and formats it as DDMMMYYYY.&amp;nbsp; The year is based on today().&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2015 18:14:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Converting-concat-char-to-concat-date-using-monyy5/m-p/236731#M55267</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-11-27T18:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: Converting concat char to concat date using monyy5.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Converting-concat-char-to-concat-date-using-monyy5/m-p/236794#M55269</link>
      <description>&lt;P&gt;And another coding option:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let rx='s/(\d+)[^\d]+(\d+).*/\1-\2-01/';

data sample;
  input Reporting_dt_Bin $5.;
  format Reporting_dt monyy5.;
  Reporting_dt=input(prxchange(&amp;amp;rx,1,Reporting_dt_Bin),yymmdd8.);
  datalines;
5-10
5- 3
15-10
15- 3
15- 4
15- 5
15- 6
15- 7
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 28 Nov 2015 02:33:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Converting-concat-char-to-concat-date-using-monyy5/m-p/236794#M55269</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-11-28T02:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Converting concat char to concat date using monyy5.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Converting-concat-char-to-concat-date-using-monyy5/m-p/236817#M55271</link>
      <description>&lt;P&gt;SAS does not have an INFORMAT for converting values in YYMM (or YY-MM) format to dates. But if you add an '-1' to the end you can use the YYMMDD informat to convert that string to a date. You could then attach the MONYY format to it. &amp;nbsp;Or use the MONYY format to convert it to a text string. &amp;nbsp;Also note that the YYMMDD format does not like the space after the hyphen in the example strings you posted. &amp;nbsp;You can use the COMPRESS() function to remove the spaces.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input reporting_dt_bin $5.;
  list;
cards;
15- 3
15- 4
15- 5
15- 6
15- 7
;
data want ;
   set have;
   date=input(cats(compress(reporting_dt_bin,' '),'-01'),yymmdd8.);
   format date monyy5.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that you could generate the REPORTING_DT_BIN without the spaces if you used:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Reporting_dt_Bin = catx('-',Reporting_year_Bin,Reporting_month_txt);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you had the month as a number you could use the Z2 format to build values that have the leading zero when month is less than 10. &amp;nbsp;This would have the advantage of both working with the YYMMDD informat and also allowing REPORTING_DT_BIN text string to sort properly.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Reporting_dt_Bin = catx('-',Reporting_year_Bin,put(input(Reporting_month_txt,2.),Z2.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Nov 2015 16:14:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Converting-concat-char-to-concat-date-using-monyy5/m-p/236817#M55271</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-11-28T16:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Converting concat char to concat date using monyy5.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Converting-concat-char-to-concat-date-using-monyy5/m-p/236819#M55272</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom﻿&lt;/a&gt; &amp;nbsp;"&lt;EM&gt;SAS does not have an INFORMAT for converting values in YYMM (or YY-MM) format to dates&lt;/EM&gt;"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Actually there is informat YYMMN which can process such strings (not with a dash though but blanks as separator seem to work).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I prefere the solution you've posted so below just for "completeness":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
  input Reporting_dt_Bin $5.;
  format Reporting_dt monyy5.;
  Reporting_dt=input(compbl(translate(Reporting_dt_Bin,' ','- ')),yymmn.);
  datalines;
5-10
5- 3
15-10
15- 3
15- 4
15- 5
15- 6
15- 7
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Nov 2015 00:17:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Converting-concat-char-to-concat-date-using-monyy5/m-p/236819#M55272</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-11-29T00:17:09Z</dc:date>
    </item>
  </channel>
</rss>

