<?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 do you impose an 'excepted value' for outliers? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-do-you-impose-an-excepted-value-for-outliers/m-p/711863#M80011</link>
    <description>&lt;P&gt;Here's a way to average the prior and post values.&amp;nbsp; You still have to decide what makes a value an outlier and incude that logic in the program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   merge have have (obs=2 keep=variable rename=(variable=subsequent));
   prior = lag(variable);
   if  /* your logic determines that current VARIABLE value is an outlier */ then do;
      if _n_=1 then capped_value = subsequent;
      else capped_value = mean(subsequent, prior);
   end;
   else capped_value = variable;
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use CAPPED_VALUE instead of VARIABLE.&lt;/P&gt;</description>
    <pubDate>Sat, 16 Jan 2021 18:06:57 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2021-01-16T18:06:57Z</dc:date>
    <item>
      <title>How do you impose an 'excepted value' for outliers?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-you-impose-an-excepted-value-for-outliers/m-p/711856#M80008</link>
      <description>&lt;P&gt;If I have outliers in my variable. How can I program SAS to find those outliers and make them the average of the previous value and the subsequent value? For example,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;if malaria cases are&amp;nbsp;1714 for Feb 2018 I want SAS to take the average between Jan 2018 (200 cases) and March 2018 (47 cases).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jan 2021 14:47:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-you-impose-an-excepted-value-for-outliers/m-p/711856#M80008</guid>
      <dc:creator>pearson101</dc:creator>
      <dc:date>2021-01-16T14:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do you impose an 'excepted value' for outliers?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-you-impose-an-excepted-value-for-outliers/m-p/711863#M80011</link>
      <description>&lt;P&gt;Here's a way to average the prior and post values.&amp;nbsp; You still have to decide what makes a value an outlier and incude that logic in the program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   merge have have (obs=2 keep=variable rename=(variable=subsequent));
   prior = lag(variable);
   if  /* your logic determines that current VARIABLE value is an outlier */ then do;
      if _n_=1 then capped_value = subsequent;
      else capped_value = mean(subsequent, prior);
   end;
   else capped_value = variable;
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use CAPPED_VALUE instead of VARIABLE.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jan 2021 18:06:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-you-impose-an-excepted-value-for-outliers/m-p/711863#M80011</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-01-16T18:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do you impose an 'excepted value' for outliers?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-you-impose-an-excepted-value-for-outliers/m-p/711877#M80013</link>
      <description>&lt;P&gt;Thank you. Can you please explain what datasets I would put&amp;nbsp; in the 2 'have' part and what 'keep 2 observations' means?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What can be place in the logic if I want the outlier to be +/- 3 SD from mean?&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jan 2021 19:24:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-you-impose-an-excepted-value-for-outliers/m-p/711877#M80013</guid>
      <dc:creator>pearson101</dc:creator>
      <dc:date>2021-01-16T19:24:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do you impose an 'excepted value' for outliers?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-you-impose-an-excepted-value-for-outliers/m-p/711892#M80014</link>
      <description>&lt;P&gt;"Have" is the name of the data set that you have that contains all the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The obs=2 tells SAS to start reading that data set with the second observation.&amp;nbsp; So one "have" starts at the first observation, and the other "have" reference starts at the second observation, thus getting the subsequent value for your variable.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jan 2021 22:14:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-you-impose-an-excepted-value-for-outliers/m-p/711892#M80014</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-01-16T22:14:17Z</dc:date>
    </item>
  </channel>
</rss>

