<?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 an Interquartile Range Across Multiple Variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Calculating-an-Interquartile-Range-Across-Multiple-Variables/m-p/587311#M14664</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/213376"&gt;@JackZ295&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Is it possible or does it make sense to calculate an interquartile range across variables? Below is a sample data set:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one; 
input response_id $ A1 A2 RF SE1 SE2 SE3 SE4 I1 I2 I3 I4 RPS; 
datalines;
1 77 86 81 84 86 83 76 81 84 83 85 82.4 
2 81 86 85 83 79 78 71 80 83 82 86 81.4 
;
run; 
proc print data=one; 
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want to find the interquartile range of the 11 values of A1-I4. I essentially want to create a new variable next to RPS that represents the interquartile range of the 11 values. For clarity the value for the RPS was generated by adding the values of A1 to I4 and dividing by the number of values (11).&lt;STRONG&gt;&lt;FONT color="#3366ff"&gt; Also, I would like the IQR to be expressed as a range from the first to third quartiles rather than difference between the first and third quartiles. Is this possible to do?&lt;/FONT&gt; &lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You should provide an actual example of what you want for that blue text. IQR is DEFINED as a difference.&lt;/P&gt;
&lt;P&gt;You can get the percentiles with the PCTL function but you don't get a single number for the range.&lt;/P&gt;
&lt;PRE&gt;data one; 
   input response_id $ A1 A2 RF SE1 SE2 SE3 SE4 I1 I2 I3 I4 RPS; 
   iqr = iqr( A1, A2, RF, SE1, SE2, SE3, SE4, I1, I2, I3, I4);
   p25 = pctl(25, A1, A2, RF, SE1, SE2, SE3, SE4, I1, I2, I3, I4);
   p75 = pctl(75, A1, A2, RF, SE1, SE2, SE3, SE4, I1, I2, I3, I4);
datalines;
1 77 86 81 84 86 83 76 81 84 83 85 82.4 
2 81 86 85 83 79 78 71 80 83 82 86 81.4 
;
run;&lt;/PRE&gt;
&lt;P&gt;If you want to bodge p25 and p75 into a single value you will need to create a character variable as desired.&lt;/P&gt;</description>
    <pubDate>Mon, 09 Sep 2019 17:11:17 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-09-09T17:11:17Z</dc:date>
    <item>
      <title>Calculating an Interquartile Range Across Multiple Variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculating-an-Interquartile-Range-Across-Multiple-Variables/m-p/587305#M14658</link>
      <description>&lt;P&gt;Is it possible or does it make sense to calculate an interquartile range across variables? Below is a sample data set:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one; 
input response_id $ A1 A2 RF SE1 SE2 SE3 SE4 I1 I2 I3 I4 RPS; 
datalines;
1 77 86 81 84 86 83 76 81 84 83 85 82.4 
2 81 86 85 83 79 78 71 80 83 82 86 81.4 
;
run; 
proc print data=one; 
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want to find the interquartile range of the 11 values of A1-I4. I essentially want to create a new variable next to RPS that represents the interquartile range of the 11 values. For clarity the value for the RPS was generated by adding the values of A1 to I4 and dividing by the number of values (11). Also, I would like the IQR to be expressed as a range from the first to third quartiles rather than difference between the first and third quartiles. Is this possible to do? &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2019 16:50:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculating-an-Interquartile-Range-Across-Multiple-Variables/m-p/587305#M14658</guid>
      <dc:creator>JackZ295</dc:creator>
      <dc:date>2019-09-09T16:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating an Interquartile Range Across Multiple Variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculating-an-Interquartile-Range-Across-Multiple-Variables/m-p/587310#M14663</link>
      <description>Sure, use the percentile function. &lt;BR /&gt;PCTL.&lt;BR /&gt;&lt;BR /&gt;RPS = mean(of A1--I4);&lt;BR /&gt;Range = catx(' - ', pctl(25, of a1-i4), pctl(75, of a1-i4);</description>
      <pubDate>Mon, 09 Sep 2019 17:08:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculating-an-Interquartile-Range-Across-Multiple-Variables/m-p/587310#M14663</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-09-09T17:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating an Interquartile Range Across Multiple Variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculating-an-Interquartile-Range-Across-Multiple-Variables/m-p/587311#M14664</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/213376"&gt;@JackZ295&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Is it possible or does it make sense to calculate an interquartile range across variables? Below is a sample data set:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one; 
input response_id $ A1 A2 RF SE1 SE2 SE3 SE4 I1 I2 I3 I4 RPS; 
datalines;
1 77 86 81 84 86 83 76 81 84 83 85 82.4 
2 81 86 85 83 79 78 71 80 83 82 86 81.4 
;
run; 
proc print data=one; 
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want to find the interquartile range of the 11 values of A1-I4. I essentially want to create a new variable next to RPS that represents the interquartile range of the 11 values. For clarity the value for the RPS was generated by adding the values of A1 to I4 and dividing by the number of values (11).&lt;STRONG&gt;&lt;FONT color="#3366ff"&gt; Also, I would like the IQR to be expressed as a range from the first to third quartiles rather than difference between the first and third quartiles. Is this possible to do?&lt;/FONT&gt; &lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You should provide an actual example of what you want for that blue text. IQR is DEFINED as a difference.&lt;/P&gt;
&lt;P&gt;You can get the percentiles with the PCTL function but you don't get a single number for the range.&lt;/P&gt;
&lt;PRE&gt;data one; 
   input response_id $ A1 A2 RF SE1 SE2 SE3 SE4 I1 I2 I3 I4 RPS; 
   iqr = iqr( A1, A2, RF, SE1, SE2, SE3, SE4, I1, I2, I3, I4);
   p25 = pctl(25, A1, A2, RF, SE1, SE2, SE3, SE4, I1, I2, I3, I4);
   p75 = pctl(75, A1, A2, RF, SE1, SE2, SE3, SE4, I1, I2, I3, I4);
datalines;
1 77 86 81 84 86 83 76 81 84 83 85 82.4 
2 81 86 85 83 79 78 71 80 83 82 86 81.4 
;
run;&lt;/PRE&gt;
&lt;P&gt;If you want to bodge p25 and p75 into a single value you will need to create a character variable as desired.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2019 17:11:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculating-an-Interquartile-Range-Across-Multiple-Variables/m-p/587311#M14664</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-09-09T17:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating an Interquartile Range Across Multiple Variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculating-an-Interquartile-Range-Across-Multiple-Variables/m-p/587313#M14665</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/213376"&gt;@JackZ295&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Is it possible or does it make sense to calculate an interquartile range across variables? Below is a sample data set:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one; 
input response_id $ A1 A2 RF SE1 SE2 SE3 SE4 I1 I2 I3 I4 RPS; 
datalines;
1 77 86 81 84 86 83 76 81 84 83 85 82.4 
2 81 86 85 83 79 78 71 80 83 82 86 81.4 
;
run; 
proc print data=one; 
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want to find the interquartile range of the 11 values of A1-I4. I essentially want to create a new variable next to RPS that represents the interquartile range of the 11 values. For clarity the value for the RPS was generated by adding the values of A1 to I4 and dividing by the number of values (11). Also, I would like the IQR to be expressed as a range from the first to third quartiles rather than difference between the first and third quartiles. Is this possible to do? &amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So the answer is, YES it is possible and others have provided code. But just because it is possible, that does not mean you SHOULD do this. The real question is, does it make any sense to do this given the source and meaning of these variables? Only you understand the problem well enough to know what these values represent, and whether it makes sense to find statistics across all of these variables. In general, I would be skeptical of doing such a calculation across different variables, without clear explanation and justification.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2019 17:14:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculating-an-Interquartile-Range-Across-Multiple-Variables/m-p/587313#M14665</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-09T17:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating an Interquartile Range Across Multiple Variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculating-an-Interquartile-Range-Across-Multiple-Variables/m-p/587318#M14667</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;writes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;iqr = iqr( A1, A2, RF, SE1, SE2, SE3, SE4, I1, I2, I3, I4);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or even simpler if appropriate&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;iqr = iqr( of A1--I4);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2019 17:59:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculating-an-Interquartile-Range-Across-Multiple-Variables/m-p/587318#M14667</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-09T17:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating an Interquartile Range Across Multiple Variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculating-an-Interquartile-Range-Across-Multiple-Variables/m-p/587319#M14668</link>
      <description>Just a note that 11 observations will not generate stable percentiles so interpretation is questionable. You can calculate it but your N's are too small to generalize or have any confidence in the data.</description>
      <pubDate>Mon, 09 Sep 2019 18:01:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculating-an-Interquartile-Range-Across-Multiple-Variables/m-p/587319#M14668</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-09-09T18:01:16Z</dc:date>
    </item>
  </channel>
</rss>

