<?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 Drop variables if mean = 0 in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Drop-variables-if-mean-0/m-p/180784#M46067</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a dataset of 1000 plus variables - all numeric. Not all of them are useful. I wanted to drop the variables where the mean if less than a threshold value. I thought of two approaches but couldn't execute either as I am a complete beginner in SAS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Approach 1: Use proc means to calculate mean of all variables in input dataset x and output it to another dataset y. Then write a step which checks dataset y where mean = 0 and matches the name with dataset x. if match = positive then delete. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Approach 2: Is there a way to write if mean of var = 0, then delete var.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 13 Jan 2015 19:43:22 GMT</pubDate>
    <dc:creator>ngnikhilgoyal</dc:creator>
    <dc:date>2015-01-13T19:43:22Z</dc:date>
    <item>
      <title>Drop variables if mean = 0</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Drop-variables-if-mean-0/m-p/180784#M46067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a dataset of 1000 plus variables - all numeric. Not all of them are useful. I wanted to drop the variables where the mean if less than a threshold value. I thought of two approaches but couldn't execute either as I am a complete beginner in SAS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Approach 1: Use proc means to calculate mean of all variables in input dataset x and output it to another dataset y. Then write a step which checks dataset y where mean = 0 and matches the name with dataset x. if match = positive then delete. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Approach 2: Is there a way to write if mean of var = 0, then delete var.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2015 19:43:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Drop-variables-if-mean-0/m-p/180784#M46067</guid>
      <dc:creator>ngnikhilgoyal</dc:creator>
      <dc:date>2015-01-13T19:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: Drop variables if mean = 0</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Drop-variables-if-mean-0/m-p/180785#M46068</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is a variant on a frequently asked question - how to drop variables that all have missing values.&lt;/P&gt;&lt;P&gt;Change the code slightly here in the first step will get you what you want. Replace the _nobs_ with _mean_&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="231530" __jive_macro_name="message" class="jive_macro jive_macro_message active_link" href="https://communities.sas.com/" modifiedtitle="true" title="Getting rid of all variables for which there are ONLY missing values"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*generate sample data;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; class;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;set&lt;/SPAN&gt; sashelp.class;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;new_var=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;univariate&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;data&lt;/SPAN&gt;=class outtable=ot(keep=_var_ _mean_) &lt;SPAN style="color: #0433ff;"&gt;noprint&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;var&lt;/SPAN&gt; _numeric_;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;sql&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0433ff;"&gt;noprint&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;select&lt;/SPAN&gt; _var_ &lt;SPAN style="color: #0433ff;"&gt;into&lt;/SPAN&gt; :vList separated &lt;SPAN style="color: #0433ff;"&gt;by&lt;/SPAN&gt; &lt;SPAN style="color: #942193;"&gt;" "&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;from&lt;/SPAN&gt; ot &lt;SPAN style="color: #0433ff;"&gt;where&lt;/SPAN&gt; _mean_=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; clean;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;set&lt;/SPAN&gt; class;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;drop&lt;/SPAN&gt; &amp;amp;vList;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2015 20:03:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Drop-variables-if-mean-0/m-p/180785#M46068</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-01-13T20:03:16Z</dc:date>
    </item>
  </channel>
</rss>

