<?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: select all the values of a variable that are not contained in the values of another variable by in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/select-all-the-values-of-a-variable-that-are-not-contained-in/m-p/282025#M57266</link>
    <description>&lt;P&gt;Please try this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want(keep=country);&lt;BR /&gt;set have;&lt;BR /&gt;if not find(strip(value_list),strip(country));&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Jul 2016 16:20:50 GMT</pubDate>
    <dc:creator>stat_sas</dc:creator>
    <dc:date>2016-07-04T16:20:50Z</dc:date>
    <item>
      <title>select all the values of a variable that are not contained in the values of another variable by obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-all-the-values-of-a-variable-that-are-not-contained-in/m-p/282023#M57265</link>
      <description>&lt;P&gt;Dear experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;assuming the following data set "have":&lt;/P&gt;&lt;P&gt;data have0;&lt;BR /&gt;country="BU"; output;&lt;BR /&gt;country="JP"; output;&lt;BR /&gt;country="US"; output;&lt;BR /&gt;run;&lt;BR /&gt;data have1;&lt;BR /&gt;value_list="US_ UK _JP NW"; output;&lt;BR /&gt;value_list="US_ UK _JP NW"; output;&lt;BR /&gt;value_list="US_ UK _JP NW"; output;&lt;BR /&gt;run;&lt;BR /&gt;data have; merge have0 have1 ;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to obtain the following one:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want&lt;BR /&gt;country="BU"; output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which is the most short, understandable and elegant way?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jul 2016 16:11:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-all-the-values-of-a-variable-that-are-not-contained-in/m-p/282023#M57265</guid>
      <dc:creator>Sir_Highbury</dc:creator>
      <dc:date>2016-07-04T16:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: select all the values of a variable that are not contained in the values of another variable by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-all-the-values-of-a-variable-that-are-not-contained-in/m-p/282025#M57266</link>
      <description>&lt;P&gt;Please try this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want(keep=country);&lt;BR /&gt;set have;&lt;BR /&gt;if not find(strip(value_list),strip(country));&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jul 2016 16:20:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-all-the-values-of-a-variable-that-are-not-contained-in/m-p/282025#M57266</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2016-07-04T16:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: select all the values of a variable that are not contained in the values of another variable by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-all-the-values-of-a-variable-that-are-not-contained-in/m-p/282029#M57268</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;HAVE

data have0;
country="BU"; output;
country="JP"; output;
country="US"; output;
run;

/*
Up to 40 obs WORK.HAVE0 total obs=3

Obs    COUNTRY

 1       BU
 2       JP
 3       US
*/


data have1;
value_list="US_ UK _JP NW"; output;
value_list="US_ UK _JP NW"; output;
value_list="US_ UK _JP NW"; output;
run;

/*
Up to 40 obs WORK.HAVE1 total obs=3

Obs     VALUE_LIST

 1     US_ UK _JP NW
 2     US_ UK _JP NW
 3     US_ UK _JP NW
*/


WANT

Up to 40 obs WORK.WANT total obs=1

Obs    COUNTRY

 1       BU


SOLUTION

* if the list does not change;
data mrg;
     merge have0 have1;
     if index(valuelist,country)=0 then output;
run;quit;


Up to 40 obs WORK.MRG total obs=1

Obs    COUNTRY     VALUELIST

 1       BU       US UK JP NW


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Jul 2016 17:25:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-all-the-values-of-a-variable-that-are-not-contained-in/m-p/282029#M57268</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2016-07-04T17:25:57Z</dc:date>
    </item>
  </channel>
</rss>

