<?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 filter data based on a condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/767878#M243502</link>
    <description>&lt;P&gt;The non related account is the record that is not listed as "Owner or Co-owner" of the account 1234&lt;/P&gt;</description>
    <pubDate>Wed, 15 Sep 2021 12:12:25 GMT</pubDate>
    <dc:creator>buddha_d</dc:creator>
    <dc:date>2021-09-15T12:12:25Z</dc:date>
    <item>
      <title>How to filter data based on a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/767874#M243498</link>
      <description>&lt;P&gt;Dear community,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I have 2 sample datasets, one is accounts table and other is table with related accounts. I need to join these tables and delete the accounts that are related. I need to have non related account only.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ACCTS;
infile cards dlm=',' MISSOVER dsd;
input ACT_NBR $ FNAME $ LNAME $ RELATION $ CNAME1 $ CNAME2 $ ;
If CNAME1 NE '' AND CNAME2 NE '' then do;
FULLNAME=STRIP(FNAME)||' '||STRIP(LNAME); 
END;
ELSE DO;
FULLNAME=STRIP(CNAME1)||''||STRIP(CNAME2);
END;
CARDS;
1234,MIKE,MEYERS,JOINT,,   
1234,MARY,MEYERS,JOINT,,
1234,JAY,MEYERS,JOINT-SO,,  
2345,,,,MEYERS,TRUST
;
RUN;



data ACCTS_RELATION;
infile cards dlm=',' MISSOVER dsd;
input ACT_NBR $ FNAME $ LNAME $ RELATION $ CNAME1 $ CNAME2 $ ;

If CNAME1 NE '' AND CNAME2 NE '' then do;
FULLNAME=STRIP(FNAME)||' '||STRIP(LNAME); 
END;
ELSE DO;
FULLNAME=STRIP(CNAME1)||''||STRIP(CNAME2);
END;

CARDS;
1234,MIKE,MEYERS,JOINT,,   
1234,MARY,MEYERS,JOINT,,
1234,JAY,MEYERS,JOINT,, 
1234,SARAH,COOKS,NOREL,,
1234,SHELLY,ROSS,JOINT-DA,,
3456,MIKE,MEYERS,JOINT,,
3456,MARY,MEYERS,JOINT,,
3456,JAY,MEYERS,JOINT-SO,, 
5678,MIKE,MEYERS,JOINT,,
2345,,,,MEYERS,TRUST
7891,,,,MEYERS,TRUST
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I need to have the output that is no relation to the accounts table (eg:1234,SARAH,COOKS,NOREL,,) only one record. I tried to make a full name and join both tables, but not able to get the output. The real data is huge, but I just wanted to get the concept here so that I can implement in bigger tables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 12:02:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/767874#M243498</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2021-09-15T12:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter data based on a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/767877#M243501</link>
      <description>&lt;P&gt;Please define what a "non-related account" is.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 12:10:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/767877#M243501</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-15T12:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter data based on a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/767878#M243502</link>
      <description>&lt;P&gt;The non related account is the record that is not listed as "Owner or Co-owner" of the account 1234&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 12:12:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/767878#M243502</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2021-09-15T12:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter data based on a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/767881#M243505</link>
      <description>&lt;P&gt;There is nothing in your data that specifies "Owner" or "Co-Owner".&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 12:14:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/767881#M243505</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-15T12:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter data based on a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/767883#M243506</link>
      <description>&lt;P&gt;It usually helps if you provide a 'want' data set in a DATALINES program like you did with the two others.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure if this captures all of what you want, but it might get you on the right path. You could also join via PROC SQL to avoid the sorting depending on the size of the dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's also making some assumptions based on duplicates. Nonetheless:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data accts_2 (drop = i);
	set accts;
	array _miss [*] _all_;
	do i = 1 to dim(_miss);
		if missing(_miss[i]) then _miss[i] = "x";
	end;
		id = catx("_", of act_nbr -- cname2);
run;

data accts_relation_2 (drop = i);
	set accts_relation;
	array _miss [*] _all_;
	do i = 1 to dim(_miss);
		if missing(_miss[i]) then _miss[i] = "x";
	end;
		id = catx("_", of act_nbr -- cname2);
run;

/* Editing to include PROC SORT...got dropped between posting. */

proc sort data = accts_2;
by id;
run;

proc sort data = accts_relation_2;
by id;
run;

data want;
	merge
			accts_2				(in = a)
			accts_relation_2	(in = b);
	by
			id;

			if b and not a;

run;

/* To avoid PROC SORT: */

proc sql;
	create table 	want2 as
		select
					t1.*
		from
					accts_relation_2 as t1
						left join
					accts_2 as t2
							on	t1.id = t2.id
		where
					t2.id is null;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;ACT_NBR FNAME LNAME RELATION CNAME1 CNAME2 FULLNAME id 
1234 JAY MEYERS JOINT x x x 1234_JAY_MEYERS_JOINT_x_x 
1234 SARAH COOKS NOREL x x x 1234_SARAH_COOKS_NOREL_x_x 
1234 SHELLY ROSS JOINT-DA x x x 1234_SHELLY_ROSS_JOINT-DA_x_x 
3456 JAY MEYERS JOINT-SO x x x 3456_JAY_MEYERS_JOINT-SO_x_x 
3456 MARY MEYERS JOINT x x x 3456_MARY_MEYERS_JOINT_x_x 
3456 MIKE MEYERS JOINT x x x 3456_MIKE_MEYERS_JOINT_x_x 
5678 MIKE MEYERS JOINT x x x 5678_MIKE_MEYERS_JOINT_x_x 
7891 x x x MEYERS TRUST x 7891_x_x_x_MEYERS_TRUST 
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 12:43:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/767883#M243506</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2021-09-15T12:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter data based on a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/767930#M243516</link>
      <description>&lt;P&gt;Sorry for not mentioning clearly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Joint means joint owner&amp;nbsp;&lt;/P&gt;&lt;P&gt;Joint-so means joint ownership (co-owner is son of the owner)&lt;/P&gt;&lt;P&gt;Joint-da means joint ownership (co-owner is daughter of the owner). Since, it is trust we don't have any one as owner but group of people.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 16:33:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/767930#M243516</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2021-09-15T16:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter data based on a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/767931#M243517</link>
      <description>&lt;P&gt;Thanks Maguiremq. But, I don't see the result I want to see from the program. Do you need any further clarification?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 16:35:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/767931#M243517</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2021-09-15T16:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter data based on a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/767940#M243521</link>
      <description>Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/139130"&gt;@buddha_d&lt;/a&gt;, it would help if you can provide a DATA step containing a DATALINES statement for what you want the final data set to look like. That way we could match exactly what you want.&lt;BR /&gt;&lt;BR /&gt;Thanks!</description>
      <pubDate>Wed, 15 Sep 2021 17:13:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/767940#M243521</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2021-09-15T17:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter data based on a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/767942#M243523</link>
      <description>&lt;P&gt;The output should look like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ACT_NBR FNAME LNAME RELATION CNAME1 CNAME2 FULLNAME id&lt;BR /&gt;1234 SARAH COOKS NOREL x x x 1234_SARAH_COOKS_NOREL_x_x&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 17:19:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/767942#M243523</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2021-09-15T17:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter data based on a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/768202#M243639</link>
      <description>&lt;P&gt;If there is an account that matches then I don't need to see that in either datasets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the data I want looks like below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ACT_NBR FNAME LNAME RELATION CNAME1 CNAME2&lt;BR /&gt;3456,MIKE,MEYERS,JOINT,,&lt;BR /&gt;3456,MARY,MEYERS,JOINT,,&lt;BR /&gt;3456,JAY,MEYERS,JOINT-SO,,&lt;BR /&gt;5678,MIKE,MEYERS,JOINT,,&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 00:07:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-filter-data-based-on-a-condition/m-p/768202#M243639</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2021-09-17T00:07:40Z</dc:date>
    </item>
  </channel>
</rss>

