<?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: Cumulative variable in SQL in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Cumulative-variable-in-SQL/m-p/50378#M13758</link>
    <description>proc sql;&lt;BR /&gt;
create table C as&lt;BR /&gt;
select&lt;BR /&gt;
   t1.netid,&lt;BR /&gt;
   t1.year,&lt;BR /&gt;
   t1.semester,&lt;BR /&gt;
  sum(t2.credits*t2.gradepoint)/sum(t2.credits) as Cumulative_GPA&lt;BR /&gt;
from&lt;BR /&gt;
   grades t1&lt;BR /&gt;
   left outer join grades t2&lt;BR /&gt;
     on t1.netid=t2.netid and t1.year=t2.year&lt;BR /&gt;
where&lt;BR /&gt;
   t2.semester le t1.semester&lt;BR /&gt;
group by &lt;BR /&gt;
  t1.netid, t1.year, t1.semester;&lt;BR /&gt;
quit;</description>
    <pubDate>Thu, 14 Apr 2011 12:02:40 GMT</pubDate>
    <dc:creator>DBailey</dc:creator>
    <dc:date>2011-04-14T12:02:40Z</dc:date>
    <item>
      <title>Cumulative variable in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Cumulative-variable-in-SQL/m-p/50376#M13756</link>
      <description>I'm working with data concerning grades by semester and year. I have been able to calculate the GPA for each individual semester as well as the overall GPA (by revising my group by statement) . Now what i want is a cumulative variable that will show what the current GPA is after any given semester. For example, if someone had this:&lt;BR /&gt;
semester 1 GPA = 3.7, semester 2 GPA = 3.1, semester 3 GPA = 2.8&lt;BR /&gt;
then the cumulative variable would be:&lt;BR /&gt;
semseter 1 CumGPA = 3.7, semester 2 CumGPA = 3.4, semester 3 CumGPA = 3.2.&lt;BR /&gt;
here is some of my code:&lt;BR /&gt;
&lt;BR /&gt;
proc sql; /*GPA per semester*/&lt;BR /&gt;
create table A as&lt;BR /&gt;
select netid, semester, year, sum(credits*gradepoint)/sum(credits) as gpa&lt;BR /&gt;
from grades&lt;BR /&gt;
group by netid, semester, year;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
proc sql; /*overall GPA*/&lt;BR /&gt;
create table B as&lt;BR /&gt;
select netid, sum(credits*gradepoint)/sum(credits) as OverallGPA&lt;BR /&gt;
from grades&lt;BR /&gt;
group by netid;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your help</description>
      <pubDate>Thu, 14 Apr 2011 06:50:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Cumulative-variable-in-SQL/m-p/50376#M13756</guid>
      <dc:creator>PCrider</dc:creator>
      <dc:date>2011-04-14T06:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative variable in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Cumulative-variable-in-SQL/m-p/50377#M13757</link>
      <description>Can you explain how to yield this cumulative variable?&lt;BR /&gt;
What is your logic ?&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Thu, 14 Apr 2011 09:47:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Cumulative-variable-in-SQL/m-p/50377#M13757</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-04-14T09:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative variable in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Cumulative-variable-in-SQL/m-p/50378#M13758</link>
      <description>proc sql;&lt;BR /&gt;
create table C as&lt;BR /&gt;
select&lt;BR /&gt;
   t1.netid,&lt;BR /&gt;
   t1.year,&lt;BR /&gt;
   t1.semester,&lt;BR /&gt;
  sum(t2.credits*t2.gradepoint)/sum(t2.credits) as Cumulative_GPA&lt;BR /&gt;
from&lt;BR /&gt;
   grades t1&lt;BR /&gt;
   left outer join grades t2&lt;BR /&gt;
     on t1.netid=t2.netid and t1.year=t2.year&lt;BR /&gt;
where&lt;BR /&gt;
   t2.semester le t1.semester&lt;BR /&gt;
group by &lt;BR /&gt;
  t1.netid, t1.year, t1.semester;&lt;BR /&gt;
quit;</description>
      <pubDate>Thu, 14 Apr 2011 12:02:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Cumulative-variable-in-SQL/m-p/50378#M13758</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2011-04-14T12:02:40Z</dc:date>
    </item>
  </channel>
</rss>

