<?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 How to exclude rows when 2 variables contain the same values? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-exclude-rows-when-2-variables-contain-the-same-values/m-p/633605#M21172</link>
    <description>&lt;P&gt;Hello everyone. Trying to figure out what code to use for the following logic. From the dataset created by the code below, I want to exclude rows where the value of dealer_state = the value of customer_state or states adjacent to the dealer_state. For example, if the dealer_state = 'OH', I would want to exclude rows where customer_state = 'OH','KY','IN','MI','WV' and 'PA'. I'm ok with hardcoding the exclusions, but don't know what that code would be. I'm using SAS 7.1 on Windows. Any suggestions? Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table New_Apps as select&lt;BR /&gt;a.application_id ,a.received_date, a.booking_date,a.market_value,&lt;BR /&gt;a.application_status,a.product_type,a.collateral_type, a.initial_decision_user_id,&lt;BR /&gt;b.dealer_state, c.customer_state, c.ssn&lt;BR /&gt;&lt;BR /&gt;from ilos.application a&lt;BR /&gt;left join ilos.company_dealer b&lt;BR /&gt;on a.dealer_id = b.dealer_id&lt;BR /&gt;left join ilos.application_search c&lt;BR /&gt;on a.application_id = c.application_id&lt;BR /&gt;where year(datepart(received_date)) &amp;gt; 2014 and&lt;BR /&gt;/* if b.dealer_state = 'OH' and c.customer_state not in (OH);*/&lt;BR /&gt;&lt;BR /&gt;;quit;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Mar 2020 14:17:27 GMT</pubDate>
    <dc:creator>ay02261</dc:creator>
    <dc:date>2020-03-20T14:17:27Z</dc:date>
    <item>
      <title>How to exclude rows when 2 variables contain the same values?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-exclude-rows-when-2-variables-contain-the-same-values/m-p/633605#M21172</link>
      <description>&lt;P&gt;Hello everyone. Trying to figure out what code to use for the following logic. From the dataset created by the code below, I want to exclude rows where the value of dealer_state = the value of customer_state or states adjacent to the dealer_state. For example, if the dealer_state = 'OH', I would want to exclude rows where customer_state = 'OH','KY','IN','MI','WV' and 'PA'. I'm ok with hardcoding the exclusions, but don't know what that code would be. I'm using SAS 7.1 on Windows. Any suggestions? Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table New_Apps as select&lt;BR /&gt;a.application_id ,a.received_date, a.booking_date,a.market_value,&lt;BR /&gt;a.application_status,a.product_type,a.collateral_type, a.initial_decision_user_id,&lt;BR /&gt;b.dealer_state, c.customer_state, c.ssn&lt;BR /&gt;&lt;BR /&gt;from ilos.application a&lt;BR /&gt;left join ilos.company_dealer b&lt;BR /&gt;on a.dealer_id = b.dealer_id&lt;BR /&gt;left join ilos.application_search c&lt;BR /&gt;on a.application_id = c.application_id&lt;BR /&gt;where year(datepart(received_date)) &amp;gt; 2014 and&lt;BR /&gt;/* if b.dealer_state = 'OH' and c.customer_state not in (OH);*/&lt;BR /&gt;&lt;BR /&gt;;quit;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 14:17:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-exclude-rows-when-2-variables-contain-the-same-values/m-p/633605#M21172</guid>
      <dc:creator>ay02261</dc:creator>
      <dc:date>2020-03-20T14:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude rows when 2 variables contain the same values?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-exclude-rows-when-2-variables-contain-the-same-values/m-p/633611#M21173</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where year(datepart(received_date)) &amp;gt; 2014 and (
(b.dealer_state = 'OH' and c.customer_state not in ('OH','KY','IN','MI,'WV'))
or (b.dealer_state = 'IN' and c.customer_state not in ('IL','IN','MI','KY','OH'))
or (b.dealer_state = 'IL' and c.customer state not in (...))&amp;nbsp;or (...)
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Mar 2020 14:25:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-exclude-rows-when-2-variables-contain-the-same-values/m-p/633611#M21173</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-20T14:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude rows when 2 variables contain the same values?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-exclude-rows-when-2-variables-contain-the-same-values/m-p/633671#M21174</link>
      <description>&lt;P&gt;Just to keep from writing such ugly code I would be tempted to create a format containing the values of the exclusion list and then simplify the where clause a bit using a slightly different logic:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc format library=work;
value $exclude
'OH' = 'OH   KY   IN   MI  WV'
;
run;

data example;
	input st1 $ st2 $;
	if indexw(put(st1,$exclude.),st2) = 0;
datalines;
OH FL
OH KY
;&lt;/PRE&gt;
&lt;P&gt;The&amp;nbsp; IN operator wouldn't allow the Put (var, fmt.) as a list builder so use indexw.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you move all of the ugly lists into the format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 16:17:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-exclude-rows-when-2-variables-contain-the-same-values/m-p/633671#M21174</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-03-20T16:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude rows when 2 variables contain the same values?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-exclude-rows-when-2-variables-contain-the-same-values/m-p/633901#M21177</link>
      <description>&lt;P&gt;Why not make an ancillary data set CHK with two variables: ST and NEIGHBORS, such as&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data chk;
  input st $2.  neighbors :$&amp;amp;20. ;
datalines;
OH  OH KY IN MI WV
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you can use it very simply in the SQL, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;...
   where received_date&amp;gt;= '01jan2015:00:00:00'dt and
   b.dealer_state=chk.state and findw(chk.neighbors,c.customer_state)=0
...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You might need to encompass the c.customer_state reference with a TRIM function if it is longer than 2 characters.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Mar 2020 00:06:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-exclude-rows-when-2-variables-contain-the-same-values/m-p/633901#M21177</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-03-22T00:06:06Z</dc:date>
    </item>
  </channel>
</rss>

