<?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: Calculate Median percent change in SAS Health and Life Sciences</title>
    <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Calculate-Median-percent-change/m-p/5018#M426</link>
    <description>Try this out, if it can be of any help:&lt;BR /&gt;
&lt;BR /&gt;
*** Merge both the dataset. If both the datasets have day variable, use it in BY for merging ***;&lt;BR /&gt;
&lt;BR /&gt;
data combine;&lt;BR /&gt;
merge data1 data2;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
*** calculat epercent change ***;&lt;BR /&gt;
&lt;BR /&gt;
data pctchg;&lt;BR /&gt;
  set combine;&lt;BR /&gt;
  pctchg=(bp2-bp1)*100/bp1;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
*** Use means to get the median ***;&lt;BR /&gt;
&lt;BR /&gt;
proc means data=pctchg median;&lt;BR /&gt;
  var pctchg;&lt;BR /&gt;
  output out=summ median=median;&lt;BR /&gt;
run;</description>
    <pubDate>Wed, 10 Oct 2007 05:11:27 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2007-10-10T05:11:27Z</dc:date>
    <item>
      <title>Calculate Median percent change</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Calculate-Median-percent-change/m-p/5017#M425</link>
      <description>I have two data sets with the same variables. Let's say for 10 observations, I want to calculate the median percent change from date1 to date2. E.g.&lt;BR /&gt;
&lt;BR /&gt;
Data set 1 values from June:&lt;BR /&gt;
BP&lt;BR /&gt;
120&lt;BR /&gt;
130&lt;BR /&gt;
90&lt;BR /&gt;
.....  &lt;BR /&gt;
&lt;BR /&gt;
Data set 2 values from September:&lt;BR /&gt;
BP&lt;BR /&gt;
110&lt;BR /&gt;
97&lt;BR /&gt;
120&lt;BR /&gt;
....&lt;BR /&gt;
&lt;BR /&gt;
What is the median percent change/difference in these values from one date to the next? I know I can do it manually but I have a lot of observations and I want to know how to do this in SAS. &lt;BR /&gt;
&lt;BR /&gt;
Thank you!</description>
      <pubDate>Tue, 09 Oct 2007 19:45:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Calculate-Median-percent-change/m-p/5017#M425</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-10-09T19:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Median percent change</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Calculate-Median-percent-change/m-p/5018#M426</link>
      <description>Try this out, if it can be of any help:&lt;BR /&gt;
&lt;BR /&gt;
*** Merge both the dataset. If both the datasets have day variable, use it in BY for merging ***;&lt;BR /&gt;
&lt;BR /&gt;
data combine;&lt;BR /&gt;
merge data1 data2;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
*** calculat epercent change ***;&lt;BR /&gt;
&lt;BR /&gt;
data pctchg;&lt;BR /&gt;
  set combine;&lt;BR /&gt;
  pctchg=(bp2-bp1)*100/bp1;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
*** Use means to get the median ***;&lt;BR /&gt;
&lt;BR /&gt;
proc means data=pctchg median;&lt;BR /&gt;
  var pctchg;&lt;BR /&gt;
  output out=summ median=median;&lt;BR /&gt;
run;</description>
      <pubDate>Wed, 10 Oct 2007 05:11:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Calculate-Median-percent-change/m-p/5018#M426</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-10-10T05:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Median percent change</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Calculate-Median-percent-change/m-p/5019#M427</link>
      <description>To me, the question is not well defined.&lt;BR /&gt;
&lt;BR /&gt;
If you want the median of the date-specific changes, then Sandeep's solution works as long as both months have the same number of days.  &lt;BR /&gt;
&lt;BR /&gt;
If you want the median percent change of all the measures in June to all the measures in September, then you want the percent change on all possible combinations of June-September measures.  This involves getting a Cartesian product of the measures in June and September and then getting the median of those combinations.  For June-September, there would be 900 (30x30) combinations.&lt;BR /&gt;
&lt;BR /&gt;
Substitute a PROC SQL for Sandeep's merge&lt;BR /&gt;
&lt;BR /&gt;
*untested code;&lt;BR /&gt;
PROC SQL;&lt;BR /&gt;
CREATE TABLE combined AS&lt;BR /&gt;
SELECT data1.BP AS BPJune,&lt;BR /&gt;
  data2.BP as BPSept&lt;BR /&gt;
FROM data1&lt;BR /&gt;
OUTER JOIN data2;&lt;BR /&gt;
QUIT;&lt;BR /&gt;
RUN;</description>
      <pubDate>Thu, 11 Oct 2007 18:32:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Calculate-Median-percent-change/m-p/5019#M427</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2007-10-11T18:32:05Z</dc:date>
    </item>
  </channel>
</rss>

