<?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 Individual Percentiles By Teacher and Fiscal Year in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Individual-Percentiles-By-Teacher-and-Fiscal-Year/m-p/309110#M66462</link>
    <description>&lt;P&gt;Do you actually have individual records for each teacher each year or is that "Total all teachers" actually the value you have in your data?&lt;/P&gt;
&lt;P&gt;And are the 350 hours of teacher A included in the 600? Are you attempting to get a common value for the quartiles across years or use a different one per year?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have individual records then Proc Rank may do this.You didn't provide enough records to do much with quartiles so I made a few up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   input teacher $ school_year  hours_spent_in_classroom;
datalines;
A   2012  350
B   2012  100
C   2012  150
D   2012   50
A   2013  150
B   2013  300
C   2013  100
D   2013  175
A   2014   50
B   2014  250
C   2014  350
D   2014  200
;
run;

proc sort data=have;
   by school_year teacher;
run;
                                                           
proc rank data=have out=want groups=4 descending;
   by school_year;
   var hours_spent_in_classroom;
   ranks HourRanking;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However if you do not individual hours for all of the teachers then this won't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that PROC rank has the first rank as 0. If you really want 1 then pass the want data set through a data step to add one to the ranks.&lt;/P&gt;</description>
    <pubDate>Thu, 03 Nov 2016 18:29:46 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-11-03T18:29:46Z</dc:date>
    <item>
      <title>Calculating Individual Percentiles By Teacher and Fiscal Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Individual-Percentiles-By-Teacher-and-Fiscal-Year/m-p/309104#M66458</link>
      <description>&lt;P&gt;I'd like to automate my SAS code to calculate what percentile (Q1,Q2,Q3,Q4) my teachers spent in the classroom by school year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My dataset looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;teacher &amp;nbsp;school_year &amp;nbsp;hours_spent_in_classroom&lt;/P&gt;&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2012 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;350&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2013 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;150&lt;/P&gt;&lt;P&gt;B&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2014 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;250&lt;/P&gt;&lt;P&gt;C&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2014 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;350&lt;/P&gt;&lt;P&gt;ALL_TEACHERS 2012 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;600&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can use proc univariate to know what percentiles are for each year. &amp;nbsp;I could hard code those percentile values into my dataset, and then do "if&amp;nbsp;hours_spent_in_classroom GE X then quartile = 1". But this is a lot of manual work, and it would change by school_year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to have a final dataset that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;teacher &amp;nbsp;school_year &amp;nbsp;hours_spent_in_classroom &amp;nbsp; Quartile&lt;/P&gt;&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2012 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;350 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2013 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;150&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;B&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2014 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;250&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/P&gt;&lt;P&gt;C&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2014 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;350&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4&lt;/P&gt;&lt;P&gt;ALL_TEACHERS 2012 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;600&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What's the best way to go about this?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 18:05:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Individual-Percentiles-By-Teacher-and-Fiscal-Year/m-p/309104#M66458</guid>
      <dc:creator>sharonlee</dc:creator>
      <dc:date>2016-11-03T18:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Individual Percentiles By Teacher and Fiscal Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Individual-Percentiles-By-Teacher-and-Fiscal-Year/m-p/309106#M66460</link>
      <description>&lt;P&gt;PROC RANK GROUPS=4&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 18:17:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Individual-Percentiles-By-Teacher-and-Fiscal-Year/m-p/309106#M66460</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-11-03T18:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Individual Percentiles By Teacher and Fiscal Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Individual-Percentiles-By-Teacher-and-Fiscal-Year/m-p/309110#M66462</link>
      <description>&lt;P&gt;Do you actually have individual records for each teacher each year or is that "Total all teachers" actually the value you have in your data?&lt;/P&gt;
&lt;P&gt;And are the 350 hours of teacher A included in the 600? Are you attempting to get a common value for the quartiles across years or use a different one per year?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have individual records then Proc Rank may do this.You didn't provide enough records to do much with quartiles so I made a few up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   input teacher $ school_year  hours_spent_in_classroom;
datalines;
A   2012  350
B   2012  100
C   2012  150
D   2012   50
A   2013  150
B   2013  300
C   2013  100
D   2013  175
A   2014   50
B   2014  250
C   2014  350
D   2014  200
;
run;

proc sort data=have;
   by school_year teacher;
run;
                                                           
proc rank data=have out=want groups=4 descending;
   by school_year;
   var hours_spent_in_classroom;
   ranks HourRanking;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However if you do not individual hours for all of the teachers then this won't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that PROC rank has the first rank as 0. If you really want 1 then pass the want data set through a data step to add one to the ranks.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 18:29:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Individual-Percentiles-By-Teacher-and-Fiscal-Year/m-p/309110#M66462</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-11-03T18:29:46Z</dc:date>
    </item>
  </channel>
</rss>

