<?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 deleting observations with several variables missing in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations-with-several-variables-missing/m-p/594932#M171062</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to delete observations with more than 10 variables recorded as 0. I have used macros so far but it is not working and I'm not familiar with array.&amp;nbsp;Each observation has 60 variables. Any suggestions would be very much appreciated. Thanks.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 09 Oct 2019 03:22:37 GMT</pubDate>
    <dc:creator>catch18</dc:creator>
    <dc:date>2019-10-09T03:22:37Z</dc:date>
    <item>
      <title>deleting observations with several variables missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations-with-several-variables-missing/m-p/594932#M171062</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to delete observations with more than 10 variables recorded as 0. I have used macros so far but it is not working and I'm not familiar with array.&amp;nbsp;Each observation has 60 variables. Any suggestions would be very much appreciated. Thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 03:22:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-observations-with-several-variables-missing/m-p/594932#M171062</guid>
      <dc:creator>catch18</dc:creator>
      <dc:date>2019-10-09T03:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: deleting observations with several variables missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations-with-several-variables-missing/m-p/594933#M171063</link>
      <description>&lt;P&gt;I should add that all the variables are numeric. Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 03:23:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-observations-with-several-variables-missing/m-p/594933#M171063</guid>
      <dc:creator>catch18</dc:creator>
      <dc:date>2019-10-09T03:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: deleting observations with several variables missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations-with-several-variables-missing/m-p/594934#M171064</link>
      <description>&lt;P&gt;If all variables are numeric you can use an array very simply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;

array myVars (*) _numeric_ ; *uses ALL numeric variables;
*array myVars (*) list of variables;

if nmiss(of myvars(*)) &amp;gt;= 10 then delete;

run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a reference that illustrates how to refer to variables and datasets in a short cut list:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And here's a tutorial on arrays.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-arrays/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-arrays/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/293117"&gt;@catch18&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have to delete observations with more than 10 variables recorded as 0. I have used macros so far but it is not working and I'm not familiar with array.&amp;nbsp;Each observation has 60 variables. Any suggestions would be very much appreciated. Thanks.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 03:38:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-observations-with-several-variables-missing/m-p/594934#M171064</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-09T03:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: deleting observations with several variables missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations-with-several-variables-missing/m-p/594938#M171067</link>
      <description>&lt;P&gt;Thanks for the links and the suggestion but the code hasn't made a difference so far. I only changed data want, set have.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 03:54:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-observations-with-several-variables-missing/m-p/594938#M171067</guid>
      <dc:creator>catch18</dc:creator>
      <dc:date>2019-10-09T03:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: deleting observations with several variables missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations-with-several-variables-missing/m-p/594945#M171069</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/293117"&gt;@catch18&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the links and the suggestion but the code hasn't made a difference so far. I only changed data want, set have.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Below code should work for counting zero's. What&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;posted would work for missings.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  array nvars {20} 8 (20*0);
  do i=1 to 20;
    nvars[i]=i;
    output;
  end;
  stop;
run;

data want;
  set have;
  array myVars _numeric_;
  _n_=0;
  do over myVars;
    if myVars=0 then 
      do;
        _n_+1;
        if _n_&amp;gt;=10 then delete;
      end;
  end;
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Oct 2019 05:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-observations-with-several-variables-missing/m-p/594945#M171069</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-10-09T05:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: deleting observations with several variables missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations-with-several-variables-missing/m-p/594946#M171070</link>
      <description>&lt;P&gt;Thanks, but could you please explain this step: &lt;SPAN class="token statement"&gt;&lt;FONT color="#0000ff"&gt;array&lt;/FONT&gt;&lt;/SPAN&gt; nvars &lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;{&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;&lt;STRONG&gt;&lt;FONT color="#008080"&gt;20&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;}&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;&lt;STRONG&gt;&lt;FONT color="#008080"&gt;8&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;(&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;&lt;STRONG&gt;&lt;FONT color="#008080"&gt;20&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;*&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;&lt;STRONG&gt;&lt;FONT color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;FONT color="#999999"&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;? &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 06:03:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-observations-with-several-variables-missing/m-p/594946#M171070</guid>
      <dc:creator>catch18</dc:creator>
      <dc:date>2019-10-09T06:03:49Z</dc:date>
    </item>
    <item>
      <title>Re: deleting observations with several variables missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations-with-several-variables-missing/m-p/594948#M171072</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/293117"&gt;@catch18&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks, but could you please explain this step: &lt;SPAN class="token statement"&gt;&lt;FONT color="#0000ff"&gt;array&lt;/FONT&gt;&lt;/SPAN&gt; nvars &lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;{&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;&lt;STRONG&gt;&lt;FONT color="#008080"&gt;20&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;}&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;&lt;STRONG&gt;&lt;FONT color="#008080"&gt;8&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;(&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;&lt;STRONG&gt;&lt;FONT color="#008080"&gt;20&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;*&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;&lt;STRONG&gt;&lt;FONT color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;FONT color="#999999"&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;? &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is just creating sample data as you haven't posted any. It creates 20 numerical variables nvars1-nvars20 populated with an initial value of 0.&lt;/P&gt;
&lt;P&gt;The array statement is documented&amp;nbsp;&lt;A href="https://go.documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=p08do6szetrxe2n136ush727sbuo.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;here&lt;/A&gt;&amp;nbsp;or start with the tutorial&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;already shared with you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 06:09:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-observations-with-several-variables-missing/m-p/594948#M171072</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-10-09T06:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: deleting observations with several variables missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations-with-several-variables-missing/m-p/594950#M171074</link>
      <description>&lt;P&gt;It definitely worked without the first data step! Many thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 06:15:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-observations-with-several-variables-missing/m-p/594950#M171074</guid>
      <dc:creator>catch18</dc:creator>
      <dc:date>2019-10-09T06:15:56Z</dc:date>
    </item>
  </channel>
</rss>

