<?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: how to use three tables to return results？ in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-three-tables-to-return-results/m-p/862318#M340609</link>
    <description>&lt;P&gt;Seems trival as long as the datasets are sorted by CODES.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data event21 ;
  input Codes $ Event21 $;
cards;
A CDC
F JFK
G BOB
;

data event22 ;
  input Codes $ Event22 $;
cards;
A EED
F UOP
G SNP-D
;

data event23 ;
  input Codes $ Event23 $;
cards;
A EED
F UOP
G SNP-D
K BDP
;

data members ;
  input MemberID DOB :mmddyy. Codes $;
  format dob yymmdd10.;
cards;
123 1/30/2021 F
456 2/28/2022 G
789 3/30/2023 K
;

data want;
  merge members(in=in1) event21-event23;
  by codes ;
  array events [2021:2023] event21-event23;
  if in1;
  if year(dob) in (2021:2023) then event = events[year(dob)];
  drop event21-event23 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1677966194490.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/81071iBB0C4A65C0FD5D85/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1677966194490.png" alt="Tom_0-1677966194490.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 04 Mar 2023 21:43:21 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-03-04T21:43:21Z</dc:date>
    <item>
      <title>how to use three tables to return results？</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-three-tables-to-return-results/m-p/862295#M340593</link>
      <description>I have three tables for event: event21, event22, event23, and one member table. How can I return Event col only based on the year of member’s birthday?&lt;BR /&gt;&lt;BR /&gt;I have tables like this:&lt;BR /&gt;Codes Event21&lt;BR /&gt;A CDC&lt;BR /&gt;F JFK&lt;BR /&gt;G BOB&lt;BR /&gt;&lt;BR /&gt;Codes Event22&lt;BR /&gt;A EED&lt;BR /&gt;F UOP&lt;BR /&gt;G SNP-D&lt;BR /&gt;Codes Event23&lt;BR /&gt;A EED&lt;BR /&gt;F UOP&lt;BR /&gt;G SNP-D&lt;BR /&gt;K BDP&lt;BR /&gt;&lt;BR /&gt;MemberID DOB Codes&lt;BR /&gt;123 1/30/2021 F&lt;BR /&gt;456 2/28/2022 G&lt;BR /&gt;789 3/30/2023 K&lt;BR /&gt;&lt;BR /&gt;I want output to be like this:&lt;BR /&gt;&lt;BR /&gt;MemberID DOB Codes Event&lt;BR /&gt;123 1/30/2021 F JFK&lt;BR /&gt;456 2/28/2022 G SNP-D&lt;BR /&gt;789 3/30/2023 K BDP&lt;BR /&gt;&lt;BR /&gt;How should I join those tables?&lt;BR /&gt;Thanks!</description>
      <pubDate>Sat, 04 Mar 2023 16:23:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-three-tables-to-return-results/m-p/862295#M340593</guid>
      <dc:creator>qc1</dc:creator>
      <dc:date>2023-03-04T16:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to use three tables to return results？</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-three-tables-to-return-results/m-p/862300#M340598</link>
      <description>&lt;P&gt;Please explain the logic you would like to use.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Mar 2023 16:34:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-three-tables-to-return-results/m-p/862300#M340598</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-03-04T16:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to use three tables to return results？</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-three-tables-to-return-results/m-p/862301#M340599</link>
      <description>If year(dob)= 2021 then event =returns event21&lt;BR /&gt;&lt;BR /&gt;Else if year(dob)=2022 then event =returns event22&lt;BR /&gt;&lt;BR /&gt;Else if year(dob)= 2023 then event = returns event23&lt;BR /&gt;&lt;BR /&gt;Else event=other&lt;BR /&gt;Something like that</description>
      <pubDate>Sat, 04 Mar 2023 16:39:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-three-tables-to-return-results/m-p/862301#M340599</guid>
      <dc:creator>qc1</dc:creator>
      <dc:date>2023-03-04T16:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to use three tables to return results？</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-three-tables-to-return-results/m-p/862318#M340609</link>
      <description>&lt;P&gt;Seems trival as long as the datasets are sorted by CODES.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data event21 ;
  input Codes $ Event21 $;
cards;
A CDC
F JFK
G BOB
;

data event22 ;
  input Codes $ Event22 $;
cards;
A EED
F UOP
G SNP-D
;

data event23 ;
  input Codes $ Event23 $;
cards;
A EED
F UOP
G SNP-D
K BDP
;

data members ;
  input MemberID DOB :mmddyy. Codes $;
  format dob yymmdd10.;
cards;
123 1/30/2021 F
456 2/28/2022 G
789 3/30/2023 K
;

data want;
  merge members(in=in1) event21-event23;
  by codes ;
  array events [2021:2023] event21-event23;
  if in1;
  if year(dob) in (2021:2023) then event = events[year(dob)];
  drop event21-event23 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1677966194490.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/81071iBB0C4A65C0FD5D85/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1677966194490.png" alt="Tom_0-1677966194490.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Mar 2023 21:43:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-three-tables-to-return-results/m-p/862318#M340609</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-04T21:43:21Z</dc:date>
    </item>
  </channel>
</rss>

