<?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 Selecting fixed number of matches in an inner join in All Things Community</title>
    <link>https://communities.sas.com/t5/All-Things-Community/Selecting-fixed-number-of-matches-in-an-inner-join/m-p/857509#M4777</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have the following code joining two tables by an unique identifier, in which a disease population is joined with a background population, creating approx 1000 matches per person in the disease population.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;

create table new as

select distinct case_id, id

from disease_pop inner join background_pop

on disease_pop.case_id = background_pop.id;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This makes a table that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;CASE_ID&lt;/TD&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;TD&gt;345&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;TD&gt;567&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;TD&gt;891&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;234&lt;/TD&gt;&lt;TD&gt;902&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;234&lt;/TD&gt;&lt;TD&gt;903&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;234&lt;/TD&gt;&lt;TD&gt;904&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Only there are approximately 1000 "IDs" for each CASE ID&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So what I want to do next is reduce the number of matches, so instead of having 1000 IDs per Case ID I would like only 10 IDs per CASE ID, but I still want to have all CASE IDs in my new table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Feb 2023 09:20:59 GMT</pubDate>
    <dc:creator>ha33</dc:creator>
    <dc:date>2023-02-07T09:20:59Z</dc:date>
    <item>
      <title>Selecting fixed number of matches in an inner join</title>
      <link>https://communities.sas.com/t5/All-Things-Community/Selecting-fixed-number-of-matches-in-an-inner-join/m-p/857509#M4777</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have the following code joining two tables by an unique identifier, in which a disease population is joined with a background population, creating approx 1000 matches per person in the disease population.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;

create table new as

select distinct case_id, id

from disease_pop inner join background_pop

on disease_pop.case_id = background_pop.id;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This makes a table that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;CASE_ID&lt;/TD&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;TD&gt;345&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;TD&gt;567&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;TD&gt;891&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;234&lt;/TD&gt;&lt;TD&gt;902&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;234&lt;/TD&gt;&lt;TD&gt;903&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;234&lt;/TD&gt;&lt;TD&gt;904&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Only there are approximately 1000 "IDs" for each CASE ID&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So what I want to do next is reduce the number of matches, so instead of having 1000 IDs per Case ID I would like only 10 IDs per CASE ID, but I still want to have all CASE IDs in my new table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 09:20:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/Selecting-fixed-number-of-matches-in-an-inner-join/m-p/857509#M4777</guid>
      <dc:creator>ha33</dc:creator>
      <dc:date>2023-02-07T09:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting fixed number of matches in an inner join</title>
      <link>https://communities.sas.com/t5/All-Things-Community/Selecting-fixed-number-of-matches-in-an-inner-join/m-p/857513#M4778</link>
      <description>&lt;P&gt;And what is the rule for reducing no of id's?&lt;/P&gt;
&lt;P&gt;There are several ways of&amp;nbsp; creating samples in SAS.&lt;/P&gt;
&lt;P&gt;In a raw data step you could do BY case_id, start a counter, and do implicit OUTPUT as long the counter is &amp;lt;= 10.&lt;/P&gt;
&lt;P&gt;Reset the counter for each new BY value (IF first.case_id THEN...).&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 09:40:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/Selecting-fixed-number-of-matches-in-an-inner-join/m-p/857513#M4778</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2023-02-07T09:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting fixed number of matches in an inner join</title>
      <link>https://communities.sas.com/t5/All-Things-Community/Selecting-fixed-number-of-matches-in-an-inner-join/m-p/857514#M4779</link>
      <description>&lt;P&gt;Thanks for you reply. There is no rule as everyone in the background population is matched by the same variables. I will attempt your suggestion.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 09:44:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/Selecting-fixed-number-of-matches-in-an-inner-join/m-p/857514#M4779</guid>
      <dc:creator>ha33</dc:creator>
      <dc:date>2023-02-07T09:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting fixed number of matches in an inner join</title>
      <link>https://communities.sas.com/t5/All-Things-Community/Selecting-fixed-number-of-matches-in-an-inner-join/m-p/858481#M4782</link>
      <description>&lt;P&gt;Hey so an update:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ended up using PROC SURVEYSELECT and defining each patient as one stratum. Worked perfectly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 08:26:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/Selecting-fixed-number-of-matches-in-an-inner-join/m-p/858481#M4782</guid>
      <dc:creator>ha33</dc:creator>
      <dc:date>2023-02-13T08:26:35Z</dc:date>
    </item>
  </channel>
</rss>

