<?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: searching for values in table A in table B using a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748708#M235161</link>
    <description>&lt;P&gt;You haven't really specifically addressed the issues raised by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;or myself, you just gone ahead and provided the same information in different words (and you have informed us the true size of data set B).&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Does the code I provided do what you want?&lt;/P&gt;</description>
    <pubDate>Thu, 17 Jun 2021 14:52:50 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-06-17T14:52:50Z</dc:date>
    <item>
      <title>searching for values in table A in table B using a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748689#M235152</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;supposing I have a table A and B as shown below&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data A;
	infile datalines;
 	input patientID $ sex $ diagnosis $8. therapie $15. age;
	datalines;
	MD10 F cancer  radiotherapy    18
	MD56 F Athritis electrotherapy 25
	MD77 M headache medication     35
	MD15 M stroke   reanimation    60

;
run;


data B;
	infile datalines;
 	input patientID $ sex $ diagnosis $9. therapie $16. age hobbys $9. pre_illness $4.;
	datalines;
	MD12 M cancer     operation      58 cinema    yes
	MD66 F allergies  medication     95 reading   no
	MD17 F headache   medication     88 swimming    
	MD11 M Cold       medication     60 hockey    yes
	MD10 F cancer     radiotherapy   18 football  no
	MD56 F Athritis   electrotherapy 25           no
	MD77 M headache   medication     35 badminton yes
	MD15 M stroke     reanimation    60 cooking     

;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and I wish to search for the patients with the same sex, diagnosis , therapy and age in table B&amp;nbsp; using a macro (preferably proc sql) without having to type in the values manually (I mean using a sort of iteration macro). How can I do that?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 14:07:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748689#M235152</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-06-17T14:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: searching for values in table A in table B using a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748691#M235153</link>
      <description>Case control matching?&lt;BR /&gt;&lt;A href="http://bioinformaticstools.mayo.edu/downloads/sas/gmatch.sas" target="_blank"&gt;http://bioinformaticstools.mayo.edu/downloads/sas/gmatch.sas&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;PROC PSMATCH is another option.&lt;BR /&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/statug/statug_psmatch_examples04.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/statug/statug_psmatch_examples04.htm&lt;/A&gt;</description>
      <pubDate>Thu, 17 Jun 2021 14:22:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748691#M235153</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-06-17T14:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: searching for values in table A in table B using a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748692#M235154</link>
      <description>&lt;P&gt;It's not clear what you mean by&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;patients with the same sex, diagnosis , therapy and age&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Do you mean that they have to have ALL four of those variables EXACTLY match in both tables? It would be helpful if you provided the desired output from these two data sets.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;It's also not clear why you are saying the solution has to contain macros, as this is often a requirement that un-necessarily complicates the coding in situations where you can achieve the desired output without macros.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here is my attempt to select records from B that match A without macros (pending on your clarification of the issues above)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    create table c as select b.* from
        b right join a
        on b.sex=a.sex and b.diagnosis=a.diagnosis and b.therapie=a.therapie and b.age=a.age;
quit;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 14:39:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748692#M235154</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-17T14:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: searching for values in table A in table B using a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748695#M235157</link>
      <description>&lt;P&gt;What would the output look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you say "same age" does that have to be exactly the same or within a range?&lt;/P&gt;
&lt;P&gt;How many records are in your sets? Matching on 4 requirements may mean there are no exact matches if your data sets are not large.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How consistent is the spelling of the therapy and diagnosis? Even you small examples show that case may not be consistent which makes matching a bit more problematic.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 14:25:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748695#M235157</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-17T14:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: searching for values in table A in table B using a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748703#M235159</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the quick reply. It's all about a research project in which a set of patients (with a specified characteristics are to be evaluated).&lt;/P&gt;
&lt;P&gt;Data A shows how these characteristics are defined (For example the patient, must be a female, be a&amp;nbsp;cancer patient, must have received a radiotherapy&amp;nbsp; and should be 18 years old).&lt;/P&gt;
&lt;P&gt;Data B is a hospital DB (with about 100 000 datasets) in which I want to search for the patients with such defined characteristics. That is the idea behind my question.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 14:49:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748703#M235159</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-06-17T14:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: searching for values in table A in table B using a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748708#M235161</link>
      <description>&lt;P&gt;You haven't really specifically addressed the issues raised by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;or myself, you just gone ahead and provided the same information in different words (and you have informed us the true size of data set B).&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Does the code I provided do what you want?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 14:52:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748708#M235161</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-17T14:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: searching for values in table A in table B using a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748709#M235162</link>
      <description>&lt;P&gt;Please show us your desired result given your (very nicely posted) sample data.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 14:53:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748709#M235162</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-06-17T14:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: searching for values in table A in table B using a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748716#M235165</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;, the desired results should look like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;'s&amp;nbsp; output, only that the comparism shouldn't be exactly 1 to 1, let's say range or similar diagnosis/therapy spelling should do.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 15:18:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748716#M235165</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-06-17T15:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: searching for values in table A in table B using a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748855#M235245</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/168930"&gt;@Anita_n&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;, the desired results should look like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;'s&amp;nbsp; output, only that the comparism shouldn't be exactly 1 to 1, let's say range or similar diagnosis/therapy spelling should do.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please be more specific ... what "range" do you mean?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We can't help you write code if you are not specific and tell us in detail exactly what you want.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 10:46:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748855#M235245</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-18T10:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: searching for values in table A in table B using a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748869#M235253</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sql;
create table want as
select * from b 
where catx(' ',sex,diagnosis,therapie,age) in 
(select catx(' ',sex,diagnosis,therapie,age) from a);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Jun 2021 12:33:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/searching-for-values-in-table-A-in-table-B-using-a-macro/m-p/748869#M235253</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-06-18T12:33:35Z</dc:date>
    </item>
  </channel>
</rss>

