<?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: Calculating Differences from Mean and Median in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Calculating-Differences-from-Mean-and-Median/m-p/276048#M58616</link>
    <description>&lt;P&gt;Why do you need if/then statements?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's code to get you started. You can calculate the percent difference and other statistics from here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=sashelp.class;
var weight;
output out=summary_stats mean=weight_avg median=weight_median;
run;

data want;
set sashelp.class;

if _n_ = 1 then set summary_stats (keep = weight:);

diff_mean = weight - weight_avg;
diff_median = weight - weight_median;

run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 08 Jun 2016 18:10:54 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-06-08T18:10:54Z</dc:date>
    <item>
      <title>Calculating Differences from Mean and Median</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculating-Differences-from-Mean-and-Median/m-p/275996#M58606</link>
      <description>&lt;P&gt;I am working on an assignment that asks to calculate:&lt;/P&gt;&lt;P&gt;1: The difference from the Mean (for each variable) as a raw difference and a percent difference&amp;nbsp;&lt;/P&gt;&lt;P&gt;2: The difference from the Median (for each variable) as a raw difference and a percent difference&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know I should start with calculating the mean/median for each variable, but is there a formula to calculate the difference and percent difference?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 15:12:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculating-Differences-from-Mean-and-Median/m-p/275996#M58606</guid>
      <dc:creator>Cloudrunner</dc:creator>
      <dc:date>2016-06-08T15:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Differences from Mean and Median</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculating-Differences-from-Mean-and-Median/m-p/276000#M58608</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Probably the easiest method is:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000146729.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000146729.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;You can then merge the mean back onto your data, and subtract the value from the calculated mean to get offset.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 15:29:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculating-Differences-from-Mean-and-Median/m-p/276000#M58608</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-06-08T15:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Differences from Mean and Median</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculating-Differences-from-Mean-and-Median/m-p/276027#M58610</link>
      <description>&lt;P&gt;Thanks for the reply. Could I also create a new dataset with the mean, and create new variables for the raw difference and percent difference using if/then statements to specify them?&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>Wed, 08 Jun 2016 16:54:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculating-Differences-from-Mean-and-Median/m-p/276027#M58610</guid>
      <dc:creator>Cloudrunner</dc:creator>
      <dc:date>2016-06-08T16:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Differences from Mean and Median</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculating-Differences-from-Mean-and-Median/m-p/276048#M58616</link>
      <description>&lt;P&gt;Why do you need if/then statements?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's code to get you started. You can calculate the percent difference and other statistics from here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=sashelp.class;
var weight;
output out=summary_stats mean=weight_avg median=weight_median;
run;

data want;
set sashelp.class;

if _n_ = 1 then set summary_stats (keep = weight:);

diff_mean = weight - weight_avg;
diff_median = weight - weight_median;

run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jun 2016 18:10:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculating-Differences-from-Mean-and-Median/m-p/276048#M58616</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-06-08T18:10:54Z</dc:date>
    </item>
  </channel>
</rss>

