<?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: Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338651#M63120</link>
    <description>&lt;P&gt;Back to my first comment - where do you call/execute the macro?&lt;/P&gt;</description>
    <pubDate>Tue, 07 Mar 2017 02:22:31 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-03-07T02:22:31Z</dc:date>
    <item>
      <title>Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338275#M63106</link>
      <description>&lt;P&gt;Actual question:&lt;/P&gt;&lt;P&gt;How to use proc sql's select case/when statements with macro by modifying the code recipe in the reference by Glenn Wright? The code that I am trying to modify here will be found on the page #10 in the reference. I also enclosed my modified code that doesn't produce data "similarity_score".&lt;/P&gt;&lt;P&gt;What am I doing wrong here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Reference: Glenn Wright, Probabilistic Record Linkage, see page #10.&lt;/P&gt;&lt;P&gt;&lt;A title="Probabilistic Record Linkage, SAS" href="http://www.wuss.org/proceedings11/Papers_Wright_G_76128.pdf" target="_self"&gt;http://www.wuss.org/proceedings11/Papers_Wright_G_76128.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Background:&lt;/P&gt;&lt;P&gt;My objective is to conduct proabilistic record linkage to reduce the duplicated entries of patients in hospital discharge data (NY).&amp;nbsp;In the absence of personal variables such as name, address, unique idnetity code, I use gender, date of birth, patient facility identifier, zip and race. The bottom line is that any rows in the data that match to each other in combination of these five variables are the most likely to represent the same person rather different. Vice versa. SAS version: 9.4 (TS1M3).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Sample" data:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
   input SEX $ DOB PFI ZIP RACE;
datalines;
F	189804	125	10111	1
M	189802	126	12365	2
F	189801	129	12369	1
M	190111	256	14236	2
F	190302	101	12144	1
M	190307	115	12203	2
M	190307	115	12203	2
M	189806	356	18963	1
F	190308	258	14789	2
F	190302	101	12144	1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Code modified from Glenn Wright: (please see reference attached)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mydata_clean (index = (obs_num sex dob pfi zip racecat)); set sample;
obs_num = _n_;
run;

%macro blocking_var(myvar);
create table similarity_score(compress=yes) as
select 
 a.obs_num    as obs_num_1,  b.obs_num as obs_num_2, 
 a.sex        as sex_1,      b.sex as sex_2, 
 a.dob        as dob_1,      b.dob as dob_2,
 a.pfi        as pfi_1,      b.pfi as pfi_2,
 a.zip        as zip_1,      b.zip as zip_2,
 a.racecat    as racecat_1,  b.racecat as racecat_2,

select 
case 
when a.sex = b.sex then 1
else -5.64 end as sex_score,

case 
when a.pfi = b.pfi then 7.6
else -4.3 end as pfi_score,

case 
when a.dob = b.dob then 3.5
else -4.2 end as dob_score,

case 
when a.racecat = b.racecat then 1
else -3.3 end as racecat_score

case 
when a.zip = b.zip then 10.6
else -4.3 end as zip_score

calculated sex_score + calculated pfi_score +
calculated dob_score + calculated racecat_score + calculated zip_score as score

from mydata_clean as a INNER JOIN mydata_clean as b
on a.obs_num &amp;gt; b.obs_num
and a.&amp;amp;myvar. = b.&amp;amp;myvar.
where a.&amp;amp;myvar. is not missing
and calculated score=&amp;lt;-10
%mend;

data threshold;
set similarity_scores;
where score =&amp;lt;-12;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Reference:&lt;/P&gt;&lt;P&gt;Glenn Wright's Probabilistic Record Linkage in SAS®, offers excellent solution to&amp;nbsp; address the problem almost identical to mine. Any hints highly appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Mar 2017 19:54:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338275#M63106</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-05T19:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338277#M63107</link>
      <description>&lt;P&gt;I might be missing something, but you defined the macro but never actually ran it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There should be a statement somewhere that looks like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
%block_var(BLOCKVAR);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Mar 2017 19:58:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338277#M63107</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-05T19:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338278#M63108</link>
      <description>&lt;P&gt;PS. Your first step should be getting the code to work exactly as defined before making changes to it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, you can take a look at the The Link King which offers a tool to create linkages based on SAS code as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Mar 2017 20:00:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338278#M63108</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-05T20:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338289#M63109</link>
      <description>&lt;P&gt;&lt;CODE&gt;Thanks Reeza,&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;Using software is not permitted in this project unfortunately. I tried taking in and out the proc sql and quit with many different variations, but still doesn't work. Wish I had sql experience but not. Please see edited code. What do you think?&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
%macro blocking_var(myvar);
create table similarity_score(compress=yes) as
select
 a.obs_num    as obs_num_1,  b.obs_num as obs_num_2,
 a.sex        as sex_1,      b.sex as sex_2,
 a.dob        as dob_1,      b.dob as dob_2,
 a.pfi        as pfi_1,      b.pfi as pfi_2,
 a.zip        as zip_1,      b.zip as zip_2,
 a.racecat    as racecat_1,  b.racecat as racecat_2,

select
case
when a.sex = b.sex then 1
else -5.64 end as sex_score,

case
when a.pfi = b.pfi then 7.6
else -4.3 end as pfi_score,

case
when a.dob = b.dob then 3.5
else -4.2 end as dob_score,

case
when a.racecat = b.racecat then 1
else -3.3 end as racecat_score

case
when a.zip = b.zip then 10.6
else -4.3 end as zip_score

calculated sex_score + calculated pfi_score +
calculated dob_score + calculated racecat_score + calculated zip_score as score

from mydata_clean as a INNER JOIN mydata_clean as b
on a.obs_num &amp;gt; b.obs_num
and a.&amp;amp;myvar. = b.&amp;amp;myvar.
where a.&amp;amp;myvar. is not missing
and calculated score=&amp;lt;-10
;
quit;
%mend;&lt;/CODE&gt; &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Mar 2017 20:34:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338289#M63109</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-05T20:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338296#M63110</link>
      <description>&lt;P&gt;Remove the macro components, get it working and then turn it into a macro. As is you're trying to debug too many things. My code was an example of how to use the macro.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're unfamiliar with the structure of the code the paper the paper did have full examples. Make sure it's the same format.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Mar 2017 20:45:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338296#M63110</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-05T20:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338301#M63111</link>
      <description>&lt;P&gt;Your code has (at least) 2 syntax errors which might go unnoticed when run inside a macro:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) the second &lt;STRONG&gt;select &lt;/STRONG&gt;keyword shouldn't be there&lt;/P&gt;
&lt;P&gt;2) there should be commas after &lt;STRONG&gt;as zip_score&lt;/STRONG&gt; and&lt;STRONG&gt; as racecat_score&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;suggested, get the code to work outside the macro before you run it as a macro. It is much easier to debug that way.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Mar 2017 21:00:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338301#M63111</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-03-05T21:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338315#M63112</link>
      <description>Thanks. Working as suggested.&lt;BR /&gt;</description>
      <pubDate>Sun, 05 Mar 2017 22:23:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338315#M63112</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-05T22:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338316#M63113</link>
      <description>Thanks. Good catches indeed.&lt;BR /&gt;</description>
      <pubDate>Sun, 05 Mar 2017 22:24:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338316#M63113</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-05T22:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338645#M63119</link>
      <description>&lt;P&gt;Hi PG,&lt;/P&gt;&lt;P&gt;I had proc sql worked outside the macro. But it loses its function when i throw it into macro. I run it but nothing happens. No data set created. What am I doing wrong here? I appreciate your time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro blocking_var(myvar);
proc sql; 
 create table similarity_scores (compress=yes) as 
 select
 a.obs_num    as obs_num_1,  b.obs_num as obs_num_2, 
 a.sex        as sex_1,      b.sex as sex_2, 
 a.dob        as dob_1,      b.dob as dob_2,
 a.pfi        as pfi_1,      b.pfi as pfi_2,
 a.zip        as zip_1,      b.zip as zip_2,
case when a.sex = b.sex then 2
     else -5 end as sex_score,
case when a.dob = b.dob then 12
     else -6 end as dob_score,
case when a.pfi = b.pfi then 10
     else -5 end as pfi_score,
case when a.zip = b.zip then 10
     else -5 end as zip_score,

calculated sex_score + calculated dob_score  + calculated pfi_score +calculated zip_score 
as total_score 
from
mydata_clean as a INNER JOIN mydata_clean as b  
 on a.obs_num &amp;gt; b.obs_num
 and a.&amp;amp;myvar.=b.&amp;amp;myvar.
 where a.&amp;amp;myvar. is not missing
 and calculated score &amp;lt;=-10  
;
quit;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Mar 2017 02:00:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338645#M63119</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-07T02:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338651#M63120</link>
      <description>&lt;P&gt;Back to my first comment - where do you call/execute the macro?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2017 02:22:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338651#M63120</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-07T02:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338652#M63121</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro blocking_var(myvar);
proc sql; 
 "union"
quit;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My last code posted included above macro elements, isn't it?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2017 02:28:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338652#M63121</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-07T02:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338655#M63122</link>
      <description>&lt;P&gt;No. That's a macro definition, you still need to execute the macro.&lt;/P&gt;
&lt;P&gt;Macro definition&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro print_demo(dataset_name);

proc print data=&amp;amp;dataset_name (obs=10);
run;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Macro execution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%print_demo(sashelp.cars);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Mar 2017 02:35:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338655#M63122</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-07T02:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338657#M63123</link>
      <description>&lt;P&gt;Like so?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%blocking_var(sex,dob,pfi,zip);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Mar 2017 02:41:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338657#M63123</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-07T02:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338658#M63124</link>
      <description>&lt;P&gt;I get:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: More positional parameters found than defined.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when I add:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%blocking_var(sex,dob,pfi,zip); &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I also tried:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%blocking_var("sex","dob","pfi","zip");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;still get the same error as above&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2017 02:50:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/338658#M63124</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-07T02:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/339246#M63136</link>
      <description>&lt;P&gt;Hi ya'll,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Still working on it. I really have to get it working.&lt;/P&gt;&lt;P&gt;Now I have macro definition and executions parts and the error I get is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7619iEA22DDFC574DF646/image-size/original?v=1.0&amp;amp;px=-1" alt="error.png" title="error.png" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro blocking_var(myvar);
proc sql; 
 create table similarity_scores (compress=yes) as 
 select
a.obs_num    as obs_num_1,  b.obs_num as obs_num_2, 
 a.sex        as sex_1,      b.sex as sex_2, 
 a.dob        as dob_1,      b.dob as dob_2,
a.pfi        as pfi_1,      b.pfi as pfi_2,
a.zip        as zip_1,      b.zip as zip_2,
case when a.sex = b.sex then 2
     else -5 end as sex_score,
case when a.dob = b.dob then 12
     else -6 end as dob_score,
case when a.pfi = b.pfi then 10
     else -5 end as pfi_score,
case when a.zip = b.zip then 10
     else -5 end as zip_score,

calculated sex_score + calculated dob_score  + calculated pfi_score +calculated zip_score 
as total_score 
from
mydata_clean as a INNER JOIN mydata_clean as b  
 on a.obs_num &amp;gt; b.obs_num
and a.&amp;amp;myvar.=b.&amp;amp;myvar.
where a.&amp;amp;myvar. is not missing
and calculated score &amp;lt;=-10  
;
quit;
%mend blocking_var;
%blocking_var(sex); 
%blocking_var(dob);
%blocking_var(pfi);
%blocking_var(zip);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any hints?&lt;/P&gt;&lt;P&gt;Thank you!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 14:09:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/339246#M63136</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-08T14:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/339750#M63181</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I know it is not the most elegant solution but it seems to work&amp;nbsp; :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; mydata_clean;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input SEX $ DOB PFI ZIP RACE;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 189804&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 125&amp;nbsp;&amp;nbsp; 10111 1&lt;/P&gt;&lt;P&gt;M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 189802&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 126&amp;nbsp;&amp;nbsp; 12365 2&lt;/P&gt;&lt;P&gt;F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 189801&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 129&amp;nbsp;&amp;nbsp; 12369 1&lt;/P&gt;&lt;P&gt;M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 190111&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 256&amp;nbsp;&amp;nbsp; 14236 2&lt;/P&gt;&lt;P&gt;F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 190302&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 101&amp;nbsp;&amp;nbsp; 12144 1&lt;/P&gt;&lt;P&gt;M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 190307&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 115&amp;nbsp;&amp;nbsp; 12203 2&lt;/P&gt;&lt;P&gt;M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 190307&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 115&amp;nbsp;&amp;nbsp; 12203 2&lt;/P&gt;&lt;P&gt;M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 189806&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 356&amp;nbsp;&amp;nbsp; 18963 1&lt;/P&gt;&lt;P&gt;F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 190308&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 258&amp;nbsp;&amp;nbsp; 14789 2&lt;/P&gt;&lt;P&gt;F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 190302&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 101&amp;nbsp;&amp;nbsp; 12144 1&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt; sqq(myvarn);&lt;/P&gt;&lt;P&gt;PROC SQL ;&lt;/P&gt;&lt;P&gt;CREATE TABLE SAMPLE2 AS&amp;nbsp;&lt;/P&gt;&lt;P&gt;SELECT * FROM mydata_clean WHERE&amp;nbsp; &amp;amp;myvarn. ="F";&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DATA&lt;/STRONG&gt; _NULL_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CALL EXECUTE('%nrstr(%sqq (sex ));');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 19:26:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/339750#M63181</guid>
      <dc:creator>atzamis</dc:creator>
      <dc:date>2017-03-09T19:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/340983#M63275</link>
      <description>Hi Reeza, I tried The Link King. This software specifically requires first and lastnames which my data doesn't have.</description>
      <pubDate>Tue, 14 Mar 2017 22:35:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/340983#M63275</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-14T22:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/340984#M63276</link>
      <description>Thanks, the code works but not for the purpose I'm trying to accomplish here.</description>
      <pubDate>Tue, 14 Mar 2017 22:38:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/340984#M63276</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-14T22:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/340986#M63277</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for all your suggestions. I gave up on macro and instead went around the problem with early threshold. Ideally, i would have taken the intersect of data resulting from each program using 5 different blocking variables using macro.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data threshold; set similarity_score;
if score =&amp;gt;17 then output threshold; run;  &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But instead, I truncated data in data step as shown above using conservative value for cut-off that made following translink program doable to my RAM.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 22:44:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/340986#M63277</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-14T22:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: Union join Proc Sql in Macro with select case when statements for Probabilistic Record Linkage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/352003#M63962</link>
      <description>&lt;P&gt;Below is macro that finally worked out, if someone would want to look at or use.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro blocking(myvar,data);
proc sql;
create table sel.&amp;amp;data as
select 
 a.obs_num    as obs_num_1,  b.obs_num  as obs_num_2, 
 a.sex        as sex_1,      b.sex      as sex_2, 
 a.birthy     as birthy_1,   b.birthy   as birthy_2,
 a.birthm     as birthm_1,   b.birthm   as birthm_2,
 a.zip        as zip_1,      b.zip      as zip_2,
 a.race       as race_1,     b.race     as race_2,
 a.ethnic     as ethnic_1,   b.ethnic   as ethnic_2,

case when a.sex = b.sex            then 1.0  else -8.0 end as sex_score,
case when a.birthy = b.birthy      then 8.8  else -4.3 end as by_score,
case when a.birthm = b.birthm      then 5.5  else -4.3 end as bm_score,
case when a.zip = b.zip            then 8.7  else -4.3 end as zip_score,
case when a.race = b.race          then 3.5  else -4.2 end as race_score,
case when a.ethnic = b.ethnic      then 0.02 else -0.4 end as eth_score,

calculated sex_score + calculated by_score + calculated bm_score + calculated zip_score+ calculated race_score+ calculated eth_score
as score
from sel.ordata as a INNER JOIN sel.ordata as b
on a.obs_num &amp;gt; b.obs_num and a.&amp;amp;myvar=b.&amp;amp;myvar 
where a.&amp;amp;myvar is not missing and calculated score ge 20;
;
quit;
%mend blocking;
%blocking(birthy,byblock1);
%blocking(birthm,bmblock1);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Apr 2017 03:43:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Union-join-Proc-Sql-in-Macro-with-select-case-when-statements/m-p/352003#M63962</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-04-21T03:43:03Z</dc:date>
    </item>
  </channel>
</rss>

