<?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: BRING BACK ALL VALUES FROM TWO DATASETS BUT ONLY IF COMMON VARIABLE IN BOTH in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/BRING-BACK-ALL-VALUES-FROM-TWO-DATASETS-BUT-ONLY-IF-COMMON/m-p/889017#M351205</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;that actually gave me the exact results I wanted!&lt;/P&gt;</description>
    <pubDate>Sat, 12 Aug 2023 02:35:03 GMT</pubDate>
    <dc:creator>JC411911</dc:creator>
    <dc:date>2023-08-12T02:35:03Z</dc:date>
    <item>
      <title>BRING BACK ALL VALUES FROM TWO DATASETS BUT ONLY IF COMMON VARIABLE IN BOTH</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BRING-BACK-ALL-VALUES-FROM-TWO-DATASETS-BUT-ONLY-IF-COMMON/m-p/889008#M351197</link>
      <description>&lt;P&gt;I may be overthinking this but I hit a block and hoping I can get some guidance. I have two datasets and I need to find the variable member_number that is common in both but also bring back all the other variables. The problem is while some variables are similar there are some that are different. Is this possible or must both datasets have the exact same variables. The first dataset is me.issue_21935_fee and has:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="10%"&gt;fee_amt&lt;/TD&gt;
&lt;TD width="10%"&gt;harm_dt&lt;/TD&gt;
&lt;TD width="10%"&gt;fee_type&lt;/TD&gt;
&lt;TD width="10%"&gt;tran_seq_nr&lt;/TD&gt;
&lt;TD width="10%"&gt;chd_origl_eff_dt&lt;/TD&gt;
&lt;TD width="10%"&gt;init_aud_pask&lt;/TD&gt;
&lt;TD width="10%"&gt;current_acct_id_nr&lt;/TD&gt;
&lt;TD width="10%"&gt;member_number&lt;/TD&gt;
&lt;TD width="10%"&gt;row_number&lt;/TD&gt;
&lt;TD width="10%"&gt;harm_amount&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;The next dataset is me.issue_21935_fin_calcs_exclusions:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="11.11111111111111%"&gt;init_aud_pask&lt;/TD&gt;
&lt;TD width="11.11111111111111%"&gt;member_number&lt;/TD&gt;
&lt;TD width="11.11111111111111%"&gt;total_harm_per_account&lt;/TD&gt;
&lt;TD width="11.11111111111111%"&gt;total_tvm_per_account&lt;/TD&gt;
&lt;TD width="11.11111111111111%"&gt;total_bdi_per_account&lt;/TD&gt;
&lt;TD width="11.11111111111111%"&gt;total_owed_per_account&lt;/TD&gt;
&lt;TD width="11.11111111111111%"&gt;total_owed_per_member&lt;/TD&gt;
&lt;TD width="11.11111111111111%"&gt;row_number&lt;/TD&gt;
&lt;TD width="11.11111111111111%"&gt;
&lt;P&gt;harm_amount&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;In reality what I need is to know what member_number appears in both datasets and show the harm amount even if they are similar or different from both datasets. Not sure if it is possible but I would like to create a new variable that shows what dataset each member_number and harm_amount is from.&lt;/P&gt;
&lt;P&gt;I tried doing an INTERSECT but that doesn't work unless I just use member_number as it is unlikely there are simimlar harm_amounts in both datasets. This unfortunately doesn't tell me what dataset or what the different harm_amounts are:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;proc sql;
	CREATE TABLE COMBINE AS
		select MEMBER_NUMBER,
			HARM_AMOUNT
		from ME.ISSUE_21935_FEE
			INTERSECT
		select MEMBER_NUMBER,
			HARM_AMOUNT
		from ME.ISSUE_21935_FIN_CALCS_EXCLUSIONS;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2023 00:08:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BRING-BACK-ALL-VALUES-FROM-TWO-DATASETS-BUT-ONLY-IF-COMMON/m-p/889008#M351197</guid>
      <dc:creator>JC411911</dc:creator>
      <dc:date>2023-08-12T00:08:21Z</dc:date>
    </item>
    <item>
      <title>Re: BRING BACK ALL VALUES FROM TWO DATASETS BUT ONLY IF COMMON VARIABLE IN BOTH</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BRING-BACK-ALL-VALUES-FROM-TWO-DATASETS-BUT-ONLY-IF-COMMON/m-p/889009#M351198</link>
      <description>&lt;P&gt;Assuming that member_number is sufficient to define a join condition that doesn't result in a many:many relation below SQL could work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table work.want as
  select 
    t1.member_number as t1_member_number,
    t1.harm_amount as t1_harm_amount,
    t2.member_number as t2_member_number,
    t2.harm_amount as t2_harm_amount
  from 
    ME.ISSUE_21935_FEE t1
    full join
    ME.ISSUE_21935_FIN_CALCS_EXCLUSIONS t2
    on t1.member_number=t2.member_number
    ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Ideally provide some sample data created via a working SAS datastep and then show us the desired result.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2023 01:07:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BRING-BACK-ALL-VALUES-FROM-TWO-DATASETS-BUT-ONLY-IF-COMMON/m-p/889009#M351198</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-08-12T01:07:08Z</dc:date>
    </item>
    <item>
      <title>Re: BRING BACK ALL VALUES FROM TWO DATASETS BUT ONLY IF COMMON VARIABLE IN BOTH</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BRING-BACK-ALL-VALUES-FROM-TWO-DATASETS-BUT-ONLY-IF-COMMON/m-p/889017#M351205</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;that actually gave me the exact results I wanted!&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2023 02:35:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BRING-BACK-ALL-VALUES-FROM-TWO-DATASETS-BUT-ONLY-IF-COMMON/m-p/889017#M351205</guid>
      <dc:creator>JC411911</dc:creator>
      <dc:date>2023-08-12T02:35:03Z</dc:date>
    </item>
  </channel>
</rss>

