<?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: SAME yymmn6 format dates are not recognized as equivalent in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAME-yymmn6-format-dates-are-not-recognized-as-equivalent/m-p/558727#M155957</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length Eligibility_Month 6.;
	input Birth_date  ddmmyy10. ID   Eligibility_Month ;
format birth_date ddmmyy10.;
datalines;
01/01/2016 0001 201511
01/01/2016 0001 201512
01/01/2016 0001 201601
01/01/2016 0001 201602
01/01/2016 0001 201603
11/11/2019 0002 201911
;
run;

data want;
set te;
o_mon=month(Birth_date);
o_yr=year(Birth_date);
if length(strip(put(o_mon,best.))) eq 1 then
birht_date_n=strip(strip(put(o_yr,best.))||'0'||strip(put(o_mon,best.)));
else birht_date_n=strip(strip(put(o_yr,best.))||strip(put(o_mon,best.)));
if input(birht_date_n,6.) eq Eligibility_Month then output;
drop o_mon o_yr birht_date_n;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 14 May 2019 18:33:59 GMT</pubDate>
    <dc:creator>singhsahab</dc:creator>
    <dc:date>2019-05-14T18:33:59Z</dc:date>
    <item>
      <title>SAME yymmn6 format dates are not recognized as equivalent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAME-yymmn6-format-dates-are-not-recognized-as-equivalent/m-p/558715#M155953</link>
      <description>&lt;P&gt;This is very bizarre and I can't figure out for the life of me why but I have some data with birth dates and eligibility dates.&amp;nbsp; The data is originally in a txt file and I am reading in the birth_date as mmddyy10.&amp;nbsp; The eligibility_month data is in numeric format and appears like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Birth_date&amp;nbsp; &amp;nbsp; &amp;nbsp;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; Eligibility_Month&lt;/P&gt;
&lt;P&gt;01/01/2016&amp;nbsp; 0001&amp;nbsp; &amp;nbsp;201511&lt;/P&gt;
&lt;P&gt;01/01/2016&amp;nbsp; 0001&amp;nbsp; &amp;nbsp;201512&lt;/P&gt;
&lt;P&gt;01/01/2016&amp;nbsp; 0001&amp;nbsp; &amp;nbsp;201601&lt;/P&gt;
&lt;P&gt;01/01/2016&amp;nbsp; 0001&amp;nbsp; &amp;nbsp;201602&lt;/P&gt;
&lt;P&gt;01/01/2016&amp;nbsp; 0001&amp;nbsp; &amp;nbsp;201603&lt;/P&gt;
&lt;P&gt;01/01/2016&amp;nbsp; 0001&amp;nbsp; &amp;nbsp;201604&lt;/P&gt;
&lt;P&gt;01/01/2016&amp;nbsp; 0001&amp;nbsp; &amp;nbsp;201605&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried reading in eligibility_month as yymmn6. and numeric, then converting it to yymmn6. using:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mom_elig_2016_3;
set mom_eligibility_2016_2; yymm=input(put(eligible_month_yyyymm, 6.), yymmn6.);
format yymm yymmn6.;
informat yymm yymmn6.;
date_my=birth_date;
format date_my yymmn6.;
informat date_my yymmn6.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The idea is to check if the birth_date = an equivalent entry in the eligibility_month.&amp;nbsp; I reformatted birth_date into the same format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For some reason, SAS recognizes SOME of the date_my and yymm as equivalent but not others.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data aa1; set mom_elig_2016_3;
if date_my=yymm; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So for example, this is inaccurate because I see records where date_my = yymm clearly equals each other but isn't picked up.&amp;nbsp; I must be missing something to do with formatting but I can't figure out what it is.&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 17:50:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAME-yymmn6-format-dates-are-not-recognized-as-equivalent/m-p/558715#M155953</guid>
      <dc:creator>appleorange</dc:creator>
      <dc:date>2019-05-14T17:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: SAME yymmn6 format dates are not recognized as equivalent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAME-yymmn6-format-dates-are-not-recognized-as-equivalent/m-p/558727#M155957</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length Eligibility_Month 6.;
	input Birth_date  ddmmyy10. ID   Eligibility_Month ;
format birth_date ddmmyy10.;
datalines;
01/01/2016 0001 201511
01/01/2016 0001 201512
01/01/2016 0001 201601
01/01/2016 0001 201602
01/01/2016 0001 201603
11/11/2019 0002 201911
;
run;

data want;
set te;
o_mon=month(Birth_date);
o_yr=year(Birth_date);
if length(strip(put(o_mon,best.))) eq 1 then
birht_date_n=strip(strip(put(o_yr,best.))||'0'||strip(put(o_mon,best.)));
else birht_date_n=strip(strip(put(o_yr,best.))||strip(put(o_mon,best.)));
if input(birht_date_n,6.) eq Eligibility_Month then output;
drop o_mon o_yr birht_date_n;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 May 2019 18:33:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAME-yymmn6-format-dates-are-not-recognized-as-equivalent/m-p/558727#M155957</guid>
      <dc:creator>singhsahab</dc:creator>
      <dc:date>2019-05-14T18:33:59Z</dc:date>
    </item>
    <item>
      <title>Re: SAME yymmn6 format dates are not recognized as equivalent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAME-yymmn6-format-dates-are-not-recognized-as-equivalent/m-p/558728#M155958</link>
      <description>&lt;P&gt;Formatting doesn't change the underlying value. Two dates can be formatted to look identical, but the underlying values are not equal, and so&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;if date_my=yymm;&lt;/PRE&gt;
&lt;P&gt;would fail.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the idea of formatting things to look the same won't help here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The act of turning eligible_month_yyyymm to character and then back to numeric also seems unnecessary. If eligible_month is numeric string, you could turn it into an actual sas day via the INPUT command. If it is numeric, something like this would work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;yymm = mdy(mod(eligibility_month,100),1,floor(eligibility_month/100));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 18:37:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAME-yymmn6-format-dates-are-not-recognized-as-equivalent/m-p/558728#M155958</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-05-14T18:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: SAME yymmn6 format dates are not recognized as equivalent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAME-yymmn6-format-dates-are-not-recognized-as-equivalent/m-p/558742#M155963</link>
      <description>You never actually lose the day component it's still there in the data, just not displayed. So if the day of the month/years don't match then it won't match. Convert both to character or use INTNX() to set the birthdates to the beginning or end of the month as needed.</description>
      <pubDate>Tue, 14 May 2019 19:27:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAME-yymmn6-format-dates-are-not-recognized-as-equivalent/m-p/558742#M155963</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-14T19:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: SAME yymmn6 format dates are not recognized as equivalent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAME-yymmn6-format-dates-are-not-recognized-as-equivalent/m-p/558746#M155964</link>
      <description>OK, that's what I was missing.  It seems like resetting the birth dates to the beginning of the month would be the simplest solution here, thanks!</description>
      <pubDate>Tue, 14 May 2019 19:43:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAME-yymmn6-format-dates-are-not-recognized-as-equivalent/m-p/558746#M155964</guid>
      <dc:creator>appleorange</dc:creator>
      <dc:date>2019-05-14T19:43:58Z</dc:date>
    </item>
  </channel>
</rss>

