<?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: Create a subset data after removing outliers in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-subset-data-after-removing-outliers/m-p/879674#M347524</link>
    <description>&lt;P&gt;Thank you mkeintz, how can I export it to an Excel worksheet?&lt;/P&gt;</description>
    <pubDate>Thu, 08 Jun 2023 00:23:01 GMT</pubDate>
    <dc:creator>mayasak</dc:creator>
    <dc:date>2023-06-08T00:23:01Z</dc:date>
    <item>
      <title>Create a subset data after removing outliers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-subset-data-after-removing-outliers/m-p/879670#M347522</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the following code to print the outliers in my data.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc print data=MDRO_Report_2021 noobs;
where abs(susceptibility-ps_mean) &amp;gt; 2*ps_std ;
by drug_bug;
var hospital_DB drug bug isolates_hospital_n isolates_tested susceptibility isolates_susceptible;
run;&lt;/PRE&gt;&lt;P&gt;I still need to remove these data from the data source so that it won't mess up my analysis.&lt;/P&gt;&lt;P&gt;Is there a way to create a dataset that is free from those outliers?&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2023 22:50:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-subset-data-after-removing-outliers/m-p/879670#M347522</guid>
      <dc:creator>mayasak</dc:creator>
      <dc:date>2023-06-07T22:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Create a subset data after removing outliers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-subset-data-after-removing-outliers/m-p/879671#M347523</link>
      <description>&lt;P&gt;Here's an analog using variable MSRP from sashelp.cars.&amp;nbsp; It has three steps (generate mean and std, generate upper and lower limits into macro variables, apply the WHERE filter:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc univariate data=sashelp.cars noprint;
  var msrp;
  output out=need mean=msrp_mean  std=msrp_std ;
run;

proc sql noprint;
  select msrp_mean - 2*msrp_std ,msrp_mean + 2*msrp_std
    into :lower_limit           ,:upper_limit
  from need;
quit;

proc print data= sashelp.cars;
  where &amp;amp;lower_limit &amp;lt;= msrp &amp;lt;= &amp;amp;upper_limit;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You might prefer to do a more non-symmetrical (no-paframetric?) outlier filter:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc univariate data=sashelp.cars noprint;
  var msrp;
  output out=need p5=p5 p95=p95;
run;

proc sql noprint;
  select p5           , p95 
    into :lower_limit ,:upper_limit
  from need;
quit;

proc print data= sashelp.cars;
  where &amp;amp;lower_limit &amp;lt;= msrp &amp;lt;= &amp;amp;upper_limit;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 13:04:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-subset-data-after-removing-outliers/m-p/879671#M347523</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-06-08T13:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: Create a subset data after removing outliers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-subset-data-after-removing-outliers/m-p/879674#M347524</link>
      <description>&lt;P&gt;Thank you mkeintz, how can I export it to an Excel worksheet?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 00:23:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-subset-data-after-removing-outliers/m-p/879674#M347524</guid>
      <dc:creator>mayasak</dc:creator>
      <dc:date>2023-06-08T00:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create a subset data after removing outliers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-subset-data-after-removing-outliers/m-p/879678#M347525</link>
      <description>&lt;P&gt;It may help to define what you mean by 'remove'. Do want to delete an entire observation? Set variables to missing? Something else?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example deleting entire observations when an outlier, assuming that is what your Where actually finds:&lt;/P&gt;
&lt;PRE&gt;Data want; 
   set MDRO_REport_2021;
   where not (abs(susceptibility-ps_mean) &amp;gt; 2*ps_std);
run;&lt;/PRE&gt;
&lt;P&gt;Or to set variables missing:&lt;/P&gt;
&lt;PRE&gt;Data want; 
   set MDRO_REport_2021;
    if abs(susceptibility-ps_mean) &amp;gt; 2*ps_std then call missing(&amp;lt;comma delimited list of variable names goes here&amp;gt;);
run;&lt;/PRE&gt;
&lt;P&gt;If remove is something other than this, describe.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 01:37:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-subset-data-after-removing-outliers/m-p/879678#M347525</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-06-08T01:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create a subset data after removing outliers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-subset-data-after-removing-outliers/m-p/880110#M347738</link>
      <description>&lt;P&gt;Thank you a lot.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 23:49:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-subset-data-after-removing-outliers/m-p/880110#M347738</guid>
      <dc:creator>mayasak</dc:creator>
      <dc:date>2023-06-11T23:49:41Z</dc:date>
    </item>
  </channel>
</rss>

