<?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: Issue when using FINDW to KEEP observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-using-FINDW-to-KEEP-observations/m-p/723080#M224328</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yay, I agree with you, even in this special case, because the style of name is similar to what is in the array so just only need&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data abc;
	set sashelp.class;
		array del_name [3] $10 _temporary_ ('John','Philip','Robert');
		do i= 1 to dim(del_name);
		if name in del_name;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Warm regards.&lt;/P&gt;</description>
    <pubDate>Wed, 03 Mar 2021 04:29:07 GMT</pubDate>
    <dc:creator>Phil_NZ</dc:creator>
    <dc:date>2021-03-03T04:29:07Z</dc:date>
    <item>
      <title>Issue when using FINDW to KEEP observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-using-FINDW-to-KEEP-observations/m-p/723062#M224320</link>
      <description>&lt;P&gt;Hi SAS Users,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Normally, I use the FINDW to delete the observation that the associated variable in the array. For example, I deal with sashelp.class&lt;/P&gt;
&lt;P&gt;The whole dataset is&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Name	Sex	Age	Height	Weight
Alfred	M	14	69	    112.5
Alice	F	13	56.5	84
Barbara	F	13	65.3	98
Carol	F	14	62.8	102.5
Henry	M	14	63.5	102.5
James	M	12	57.3	83
Jane	F	12	59.8	84.5
Janet	F	15	62.5	112.5
Jeffrey	M	13	62.5	84
John	M	12	59	    99.5
Joyce	F	11	51.3	50.5
Judy	F	14	64.3	90
Louise	F	12	56.3	77
Mary	F	15	66.5	112
Philip	M	16	72	    150
Robert	M	12	64.8	128
Ronald	M	15	67	    133
Thomas	M	11	57.5	85
William	M	15	66.5	112&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When I want to exclude observations that have name&amp;nbsp;'John','Philip','Robert', I have the code as below&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data abc;
	set sashelp.class;
		array del_name [3] $10 _temporary_ ('John','Philip','Robert');
		do i= 1 to dim(del_name);
		if findw(Name,del_name[i],'','eir')&amp;gt;0 then delete;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And it works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Name	Sex	Age	Height	Weight	i
Alfred	M	14	69	    112.5	4
Alice	F	13	56.5	84	    4
Barbara	F	13	65.3	98	    4
Carol	F	14	62.8	102.5	4
Henry	M	14	63.5	102.5	4
James	M	12	57.3	83	    4
Jane	F	12	59.8	84.5	4
Janet	F	15	62.5	112.5	4
Jeffrey	M	13	62.5	84	    4
Joyce	F	11	51.3	50.5	4
Judy	F	14	64.3	90	    4
Louise	F	12	56.3	77	    4
Mary	F	15	66.5	112	    4
Ronald	M	15	67	    133	    4
Thomas	M	11	57.5	85	    4
William	M	15	66.5	112	    4&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;HOWEVER, when &lt;STRONG&gt;I try to do the opposite thing, keeping observations that have the&amp;nbsp;name&amp;nbsp;'John','Philip','Robert'&lt;/STRONG&gt;, I run the code below&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data abc;
	set sashelp.class;
		array del_name [3] $10 _temporary_ ('John','Philip','Robert');
		do i= 1 to dim(del_name);
		if findw(Name,del_name[i],'','eir')=0 then delete;
		Comment this is the only line I changed;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The result is as below&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="My97_0-1614740686416.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55385iEAF420485697CA3A/image-size/large?v=v2&amp;amp;px=999" role="button" title="My97_0-1614740686416.png" alt="My97_0-1614740686416.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;with the log is&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.ABC has 0 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Could you please let me know what I did wrong in this code (I must use an &lt;STRONG&gt;array&lt;/STRONG&gt; here because my real case is much more complex) ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warm regards.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 03:08:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-when-using-FINDW-to-KEEP-observations/m-p/723062#M224320</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-03-03T03:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Issue when using FINDW to KEEP observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-using-FINDW-to-KEEP-observations/m-p/723065#M224321</link>
      <description>&lt;P&gt;In your second example, for a row to be kept, John AND Philip AND Robert must be ALL be present. No rows meet this condition.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 03:36:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-when-using-FINDW-to-KEEP-observations/m-p/723065#M224321</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-03-03T03:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Issue when using FINDW to KEEP observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-using-FINDW-to-KEEP-observations/m-p/723066#M224322</link>
      <description>&lt;P&gt;This will get you what you want - note the use of the implicit boolean condition:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data abc;
	set sashelp.class;
		array del_name [3] $10 _temporary_ ('John','Philip','Robert');
		do i= 1 to dim(del_name);
		if findw(Name,del_name[i],'','eir');
		Comment this is the only line I changed;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Mar 2021 03:43:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-when-using-FINDW-to-KEEP-observations/m-p/723066#M224322</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-03-03T03:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: Issue when using FINDW to KEEP observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-using-FINDW-to-KEEP-observations/m-p/723068#M224323</link>
      <description>&lt;P&gt;&amp;nbsp;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for yoru explanation, you are right about the logical line.&lt;/P&gt;
&lt;P&gt;Regarding the code, unfortunately, I copy the code to my SAS and it still result in blank&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;28         data abc;
29         	set sashelp.class;
30         		array del_name [3] $10 _temporary_ ('John','Philip','Robert');
31         		do i= 1 to dim(del_name);
32         		if findw(Name,del_name[i],'','eir');
33         		Comment this is the only line I changed;
34            end;
35         run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.ABC has 0 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;result:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="My97_0-1614743439276.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55386i678B834BCD59BA80/image-size/large?v=v2&amp;amp;px=999" role="button" title="My97_0-1614743439276.png" alt="My97_0-1614743439276.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warm regards.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 03:50:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-when-using-FINDW-to-KEEP-observations/m-p/723068#M224323</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-03-03T03:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Issue when using FINDW to KEEP observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-using-FINDW-to-KEEP-observations/m-p/723073#M224325</link>
      <description>&lt;P&gt;The subsetting IF in the do loop doesn't do what you need.&amp;nbsp; Instead the IF test should have a "then output" action:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data abc;
	set sashelp.class;
		array del_name [3] $10 _temporary_ ('John','Philip','Robert');
		do i= 1 to dim(del_name);
		if findw(Name,del_name[i],'','eir') then output;
		Comment this is the only line I changed;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Most observations will fail all 3 if tests.&amp;nbsp; But 3 of them will pass once each.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 03:57:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-when-using-FINDW-to-KEEP-observations/m-p/723073#M224325</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-03-03T03:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: Issue when using FINDW to KEEP observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-using-FINDW-to-KEEP-observations/m-p/723074#M224326</link>
      <description>&lt;P&gt;You could also replace the loop with&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;if propcase(name) in del_name;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to keep, or&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;if propcase(name) in del_name then delete;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to drop the names listed in the temp array.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 03:58:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-when-using-FINDW-to-KEEP-observations/m-p/723074#M224326</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-03-03T03:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: Issue when using FINDW to KEEP observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-using-FINDW-to-KEEP-observations/m-p/723078#M224327</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is very interesting, I need to admit that I was very close to your answer, just I use "put" instead of "output":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data abc;
	set sashelp.class;
		array del_name [3] $10 _temporary_ ('John','Philip','Robert');
		do i= 1 to dim(del_name);
		if findw(Name,del_name[i],'','eir')then put;
		Comment I used "put" here instead of "output";
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And I was stuck because it results in all observation&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="My97_0-1614745033925.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55387iA2AC119523225946/image-size/large?v=v2&amp;amp;px=999" role="button" title="My97_0-1614745033925.png" alt="My97_0-1614745033925.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Then I went for a search if there is any difference between "put" and "output", results in &lt;A href="https://v8doc.sas.com/sashtml/lgref/z0161869.htm#:~:text=Both%20the%20PUT%20and%20OUTPUT,to%20a%20SAS%20data%20set." target="_self"&gt;this document&lt;/A&gt;. In which, they said:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Both the PUT and OUTPUT statements create output in a DATA step. The PUT statement uses an output buffer and writes output lines to a file, the SAS log, or your display. The OUTPUT statement uses the program data vector and writes observations to a SAS data set.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There seems to be no clear difference between PUT and OUTPUT in my case being explained thoroughly here.&lt;/P&gt;
&lt;P&gt;Could you please give me a hint about that?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warmest regards.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 04:21:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-when-using-FINDW-to-KEEP-observations/m-p/723078#M224327</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-03-03T04:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: Issue when using FINDW to KEEP observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-using-FINDW-to-KEEP-observations/m-p/723080#M224328</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yay, I agree with you, even in this special case, because the style of name is similar to what is in the array so just only need&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data abc;
	set sashelp.class;
		array del_name [3] $10 _temporary_ ('John','Philip','Robert');
		do i= 1 to dim(del_name);
		if name in del_name;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Warm regards.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 04:29:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-when-using-FINDW-to-KEEP-observations/m-p/723080#M224328</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-03-03T04:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: Issue when using FINDW to KEEP observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-when-using-FINDW-to-KEEP-observations/m-p/723216#M224387</link>
      <description>&lt;P&gt;You don't need the loop&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data abc;
set sashelp.class;
array del_name [3] $10 _temporary_ ('John','Philip','Robert');
if propcase(name) in del_name;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Mar 2021 17:32:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-when-using-FINDW-to-KEEP-observations/m-p/723216#M224387</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-03-03T17:32:46Z</dc:date>
    </item>
  </channel>
</rss>

