<?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 can I remove certain values of variable while other variable meets the condition? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-remove-certain-values-of-variable-while-other-variable/m-p/496500#M131335</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/233042"&gt;@MonoLight&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;Should I use Data? or Sql? (I'm not familiar with Sql though)&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A data-step. in my eyes sql-code is almost always ugly mess.&lt;/P&gt;</description>
    <pubDate>Tue, 18 Sep 2018 09:17:31 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2018-09-18T09:17:31Z</dc:date>
    <item>
      <title>How can I remove certain values of variable while other variable meets the condition?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-remove-certain-values-of-variable-while-other-variable/m-p/496487#M131327</link>
      <description>&lt;P&gt;Hi there.&lt;/P&gt;&lt;P&gt;If I have a data like below,&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
Input A1 A2 A3 A4;
Cards;
1 2 3 4
1 3 4 2
1 2 3 2
2 3 2 3
2 3 4 2
2 4 5 3
3 2 4 3
3 3 4 2
;
Run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to make a condition that, if S1=1, delete S2's value which is in same row of S1=1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the result should be like this.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have2;
Input A1 A2 A3 A4;
Cards;
1 . 3 4
1 . 4 2
1 . 3 2
2 3 2 3
2 3 4 2
2 4 5 3
3 2 4 3
3 3 4 2
;
Run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And please let me know the way I can keep the values of S2 where value of S1=1, but remove others.&lt;/P&gt;&lt;P&gt;It should be like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have3;
Input A1 A2 A3 A4;
Cards;
1 2 3 4
1 3 4 2
1 2 3 2
2 . 2 3
2 . 4 2
2 . 5 3
3 . 4 3
3 . 4 2
;
Run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the great help and advice in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 07:50:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-remove-certain-values-of-variable-while-other-variable/m-p/496487#M131327</guid>
      <dc:creator>MonoLight</dc:creator>
      <dc:date>2018-09-18T07:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: How can I remove certain values of variable while other variable meets the condition?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-remove-certain-values-of-variable-while-other-variable/m-p/496489#M131328</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Delete A2 when A1=1 :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if A1=1 then A2=.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;or&lt;/P&gt;
&lt;P&gt;if A1=1 then call missing(A2);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Delete A2 when A1 != 1 :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if A1 ne 1 then A2=.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 08:21:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-remove-certain-values-of-variable-while-other-variable/m-p/496489#M131328</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-09-18T08:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: How can I remove certain values of variable while other variable meets the condition?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-remove-certain-values-of-variable-while-other-variable/m-p/496497#M131332</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;Should I use Data? or Sql? (I'm not familiar with Sql though)&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 09:09:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-remove-certain-values-of-variable-while-other-variable/m-p/496497#M131332</guid>
      <dc:creator>MonoLight</dc:creator>
      <dc:date>2018-09-18T09:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: How can I remove certain values of variable while other variable meets the condition?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-remove-certain-values-of-variable-while-other-variable/m-p/496498#M131333</link>
      <description>&lt;P&gt;Data step is fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
Input A1 A2 A3 A4;

if A1=1 then A2=.;
Cards;
1 2 3 4
1 3 4 2
1 2 3 2
2 3 2 3
2 3 4 2
2 4 5 3
3 2 4 3
3 3 4 2
;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With proc sql you could do&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    UPDATE have
    SET A2=.
    WHERE A1=1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Sep 2018 09:14:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-remove-certain-values-of-variable-while-other-variable/m-p/496498#M131333</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-09-18T09:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: How can I remove certain values of variable while other variable meets the condition?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-remove-certain-values-of-variable-while-other-variable/m-p/496499#M131334</link>
      <description>&lt;P&gt;Wow, Thank you gamotte!&lt;/P&gt;&lt;P&gt;I really appreciate it!&lt;/P&gt;&lt;P&gt;I didn't know I can write condition before input.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you again!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 09:15:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-remove-certain-values-of-variable-while-other-variable/m-p/496499#M131334</guid>
      <dc:creator>MonoLight</dc:creator>
      <dc:date>2018-09-18T09:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: How can I remove certain values of variable while other variable meets the condition?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-remove-certain-values-of-variable-while-other-variable/m-p/496500#M131335</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/233042"&gt;@MonoLight&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;Should I use Data? or Sql? (I'm not familiar with Sql though)&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A data-step. in my eyes sql-code is almost always ugly mess.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 09:17:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-remove-certain-values-of-variable-while-other-variable/m-p/496500#M131335</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-09-18T09:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: How can I remove certain values of variable while other variable meets the condition?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-remove-certain-values-of-variable-while-other-variable/m-p/496504#M131338</link>
      <description>&lt;PRE class=" language-sas"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;If I want to delete A2's values if A1 is not 1,&lt;/P&gt;&lt;P&gt;Can I just use this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;sql&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="token keyword"&gt;UPDATE&lt;/SPAN&gt; have
    &lt;SPAN class="token keyword"&gt;SET&lt;/SPAN&gt; A2&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;
    &lt;SPAN class="token statement"&gt;WHERE&lt;/SPAN&gt; A1 !&lt;SPAN class="token operator"&gt;= &lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;quit&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And actually I'm trying to delete A2s if A1's value is certain characters.&lt;/P&gt;&lt;P&gt;It keeps making error with != ...&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 09:32:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-remove-certain-values-of-variable-while-other-variable/m-p/496504#M131338</guid>
      <dc:creator>MonoLight</dc:creator>
      <dc:date>2018-09-18T09:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: How can I remove certain values of variable while other variable meets the condition?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-remove-certain-values-of-variable-while-other-variable/m-p/496508#M131340</link>
      <description>"!=" is not a valid operator in SAS. Use "ne" or "^=".</description>
      <pubDate>Tue, 18 Sep 2018 09:41:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-remove-certain-values-of-variable-while-other-variable/m-p/496508#M131340</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-09-18T09:41:57Z</dc:date>
    </item>
  </channel>
</rss>

