<?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: Flagging low risk, date of birth changes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292833#M270133</link>
    <description>&lt;P&gt;correct, it will be included...&lt;/P&gt;</description>
    <pubDate>Fri, 19 Aug 2016 19:54:44 GMT</pubDate>
    <dc:creator>brulard</dc:creator>
    <dc:date>2016-08-19T19:54:44Z</dc:date>
    <item>
      <title>Flagging low risk, date of birth changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292802#M270127</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm seeking guidance toward building&amp;nbsp; code that can modify aspects of a date, specifically the customer's date of birth (dob).The purpose&amp;nbsp; is to pinpoint potential fraud (as a dob typically never changes, unless due to data entry error, or fraud).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example variables:&amp;nbsp;&amp;nbsp; old_birthday: 01jan1980&amp;nbsp;&amp;nbsp; | new_birthday: 03mar1982. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Format of birthday is date9., using SAS 9.4. I need to flag those where the change in the dob is low risk, such as those meeting the two below conditions:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From first variable (old_birthday):&amp;nbsp;&lt;/P&gt;&lt;P&gt;A-Reverse last two digit of year. Example: have 05jan19&lt;STRONG&gt;&lt;U&gt;67&lt;/U&gt;&lt;/STRONG&gt; want 05jan19&lt;STRONG&gt;&lt;U&gt;76&lt;/U&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;B-Swap day with month. Example: have &lt;STRONG&gt;&lt;U&gt;05jan&lt;/U&gt;&lt;/STRONG&gt;1980 want &lt;STRONG&gt;&lt;U&gt;01may&lt;/U&gt;&lt;/STRONG&gt;1980&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If want=new_birthday then do;High_Risk=’N’;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions are highly appreciated, thanks in advance,&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 18:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292802#M270127</guid>
      <dc:creator>brulard</dc:creator>
      <dc:date>2016-08-19T18:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging low risk, date of birth changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292812#M270128</link>
      <description>&lt;P&gt;Test against dateA and dateB given by:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
do date = '05jan1967'd,'05jan1980'd;
    dateA = mdy(month(date), day(date), 
	   100*int(year(date)/100) + 10*mod(year(date), 10) + mod(int(year(date)/10), 10));
    dateB = mdy(day(date), month(date), year(date));
    put (date datea dateb) (=yymmdd10.);
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Aug 2016 18:58:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292812#M270128</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-08-19T18:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging low risk, date of birth changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292818#M270129</link>
      <description>&lt;P&gt;Put it back to Char, then we are&amp;nbsp;playing a Char game, this is just one of the possible solutions,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
format old_dt new_dt date9.;
old_dt='05jan1969'd;new_dt='5jan1996'd;output;
old_dt='5jan1980'd;new_dt='1may1980'd;output;
run;

data want;
set have;
_old=put(old_dt,yymmdd8.);
_new=put(new_dt,yymmdd8.);
if _old ne _new then do;
if _new=prxchange('s/(^\d)(\d)/$2$1/oi',-1,_old) then flag_a=1;
if _new=prxchange('s/(-\d\d)(-\d\d$)/$2$1/oi',-1,_old) then flag_b=1;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Aug 2016 19:17:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292818#M270129</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-08-19T19:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging low risk, date of birth changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292824#M270130</link>
      <description>&lt;P&gt;very interesting! Could you help me add 3 more flags to your code?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-if difference in old date and new date, is either -1, or 1 in either day month or year. Here's the code I had created:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;dd=day(new_birthday)-day(old_birthday);
mm=month(new_birthday)-month(old_birthday);  
yy=year(new_birthday)-year(old_birthday);
if dd in (-1,1) then do; FLAG_D=1;END;
IF MM  in (-1,1) then do; FLAG_M=1;END;
IF YY in (-1,1) then do; FLAG_Y=1;END;&lt;/PRE&gt;&lt;P&gt;i'm fairly new to sas.. thank you&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 19:41:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292824#M270130</guid>
      <dc:creator>brulard</dc:creator>
      <dc:date>2016-08-19T19:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging low risk, date of birth changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292825#M270131</link>
      <description>&lt;P&gt;*set everything that has different birthdays as high risk;&lt;/P&gt;&lt;P&gt;if&amp;nbsp;old_birthday -new_birthday&amp;gt;0 then flag="highrisk";&lt;/P&gt;&lt;P&gt;&amp;nbsp; else flag="lowrisk";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*set those with reversed day months back to low risk;&lt;/P&gt;&lt;P&gt;if (month(new_birthday)=day(old_birthday) or day(new_birthday)=month(old_birthday) then flag="lowrisk";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*separate out the last and second last digits in year;&lt;/P&gt;&lt;P&gt;yearold=year(old_birthday);&lt;/P&gt;&lt;P&gt;yearnew=year(new_birthday);&lt;/P&gt;&lt;P&gt;yearlastdigitnew= yearnew-int(yearnew/10)*10;&lt;/P&gt;&lt;P&gt;yearlastdigitold=yearold-int(yearold/10)*10;&lt;/P&gt;&lt;P&gt;year2ndlastdigitnew=int(yearnew/10)-int(yearnew/100)*10;&lt;/P&gt;&lt;P&gt;year2ndlastdigitold=int(yearold/10)-int(yearold/100)*10;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*set those with reverse last year digits to low risk;&lt;/P&gt;&lt;P&gt;if (yearlastdigitnew=year2ndlastdigitold) or (yearlastdigitold=year2ndlastdigitnew) then flag="lowrisk";&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 19:44:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292825#M270131</guid>
      <dc:creator>Avery</dc:creator>
      <dc:date>2016-08-19T19:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging low risk, date of birth changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292831#M270132</link>
      <description>&lt;P&gt;I think this code checks if the new and the old days, months and years are within 1 of each other.&amp;nbsp; ie. Its checking for a different kind of typo&amp;nbsp;&amp;nbsp;than&amp;nbsp;requested in&amp;nbsp;the original post (ie. typing 7 when you meant &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt;&amp;nbsp;but still very relevant as it's&amp;nbsp;likely to&amp;nbsp;be low risk&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 19:52:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292831#M270132</guid>
      <dc:creator>Avery</dc:creator>
      <dc:date>2016-08-19T19:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging low risk, date of birth changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292833#M270133</link>
      <description>&lt;P&gt;correct, it will be included...&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 19:54:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292833#M270133</guid>
      <dc:creator>brulard</dc:creator>
      <dc:date>2016-08-19T19:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging low risk, date of birth changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292837#M270134</link>
      <description>&lt;P&gt;If you are loking for typos, you could use the edit distance with a small cutoff value:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;match = complev(put(date1, yymmdd10.), put(date2, yymmdd10.), 1) &amp;lt;= 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look at the description of the complev distance function in the documentation.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 20:02:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292837#M270134</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-08-19T20:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging low risk, date of birth changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292841#M270135</link>
      <description>thanks Avery, your solution works as well ... appreciate the explanations offered.</description>
      <pubDate>Fri, 19 Aug 2016 20:20:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292841#M270135</guid>
      <dc:creator>brulard</dc:creator>
      <dc:date>2016-08-19T20:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging low risk, date of birth changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292845#M270136</link>
      <description>Thanks for your help and for this tip ... I will research the complev function</description>
      <pubDate>Fri, 19 Aug 2016 20:46:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-low-risk-date-of-birth-changes/m-p/292845#M270136</guid>
      <dc:creator>brulard</dc:creator>
      <dc:date>2016-08-19T20:46:11Z</dc:date>
    </item>
  </channel>
</rss>

