<?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 Calculating Trend for Each Group of Observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Trend-for-Each-Group-of-Observations/m-p/634289#M188254</link>
    <description>&lt;P&gt;Hey all!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; TERM&amp;nbsp; CUR GPA&lt;/P&gt;&lt;P&gt;ABC 1 3.5&lt;/P&gt;&lt;P&gt;ABC 2 3.67&lt;/P&gt;&lt;P&gt;ABC 3 3.43&lt;/P&gt;&lt;P&gt;XYZ 1 2.67&lt;/P&gt;&lt;P&gt;XYZ 2 2.69&lt;/P&gt;&lt;P&gt;XYZ 3 3.01&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to calculate the Percent change for each group of Student ID and then the trend for each term.&lt;/P&gt;&lt;P&gt;I have been trying to calculate the percent change for each student ID as:&lt;/P&gt;&lt;P&gt;a = lag(CUR_GPA)&lt;/P&gt;&lt;P&gt;change = ((current-a)/a)&lt;/P&gt;&lt;P&gt;mean = mean(change)&lt;/P&gt;&lt;P&gt;If I follow this the 'a' value for each first student ID will be 0 because I wish to group by each ID and do these calculations on particular groups.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 23 Mar 2020 22:33:58 GMT</pubDate>
    <dc:creator>rj997</dc:creator>
    <dc:date>2020-03-23T22:33:58Z</dc:date>
    <item>
      <title>Calculating Trend for Each Group of Observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Trend-for-Each-Group-of-Observations/m-p/634289#M188254</link>
      <description>&lt;P&gt;Hey all!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; TERM&amp;nbsp; CUR GPA&lt;/P&gt;&lt;P&gt;ABC 1 3.5&lt;/P&gt;&lt;P&gt;ABC 2 3.67&lt;/P&gt;&lt;P&gt;ABC 3 3.43&lt;/P&gt;&lt;P&gt;XYZ 1 2.67&lt;/P&gt;&lt;P&gt;XYZ 2 2.69&lt;/P&gt;&lt;P&gt;XYZ 3 3.01&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to calculate the Percent change for each group of Student ID and then the trend for each term.&lt;/P&gt;&lt;P&gt;I have been trying to calculate the percent change for each student ID as:&lt;/P&gt;&lt;P&gt;a = lag(CUR_GPA)&lt;/P&gt;&lt;P&gt;change = ((current-a)/a)&lt;/P&gt;&lt;P&gt;mean = mean(change)&lt;/P&gt;&lt;P&gt;If I follow this the 'a' value for each first student ID will be 0 because I wish to group by each ID and do these calculations on particular groups.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 22:33:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Trend-for-Each-Group-of-Observations/m-p/634289#M188254</guid>
      <dc:creator>rj997</dc:creator>
      <dc:date>2020-03-23T22:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Trend for Each Group of Observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Trend-for-Each-Group-of-Observations/m-p/634296#M188255</link>
      <description>&lt;P&gt;Do you want a trend, or do your want record-by-record changes? &amp;nbsp; You code suggests the latter while you title suggest the former?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide a example of how you want the results to look like.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 22:50:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Trend-for-Each-Group-of-Observations/m-p/634296#M188255</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-03-23T22:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Trend for Each Group of Observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Trend-for-Each-Group-of-Observations/m-p/634297#M188256</link>
      <description>&lt;P&gt;Hey! Thanks for replying.&lt;/P&gt;&lt;P&gt;I want to calculate the trend based on the record by record change i.e. a mean of the change.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 22:57:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Trend-for-Each-Group-of-Observations/m-p/634297#M188256</guid>
      <dc:creator>rj997</dc:creator>
      <dc:date>2020-03-23T22:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Trend for Each Group of Observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Trend-for-Each-Group-of-Observations/m-p/634309#M188258</link>
      <description>&lt;P&gt;And I repeat, how do your want you output to look?&amp;nbsp; Do you want a report, without saving a new dataset file?&amp;nbsp; Do you want a dataset with one observation per id, containing a new average percent change?&amp;nbsp; Something else?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 00:35:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Trend-for-Each-Group-of-Observations/m-p/634309#M188258</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-03-24T00:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Trend for Each Group of Observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Trend-for-Each-Group-of-Observations/m-p/634496#M188316</link>
      <description>&lt;P&gt;I am trying to create a new data set with one observation per id.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 17:12:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Trend-for-Each-Group-of-Observations/m-p/634496#M188316</guid>
      <dc:creator>rj997</dc:creator>
      <dc:date>2020-03-24T17:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Trend for Each Group of Observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Trend-for-Each-Group-of-Observations/m-p/634912#M188473</link>
      <description>&lt;P&gt;You apparently want the average relative change within a group, &lt;EM&gt;&lt;STRONG&gt;not&lt;/STRONG&gt;&lt;/EM&gt; a trend as defined by a regression line slope.&amp;nbsp; If so:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input ID $3. TERM  CUR_GPA;
datalines;
ABC 1 3.5
ABC 2 3.67
ABC 3 3.43
XYZ 1 2.67
XYZ 2 2.69
XYZ 3 3.01
run;
data want (keep=id mean_dif);
  set have;
  by id;
  difsum+dif(cur_gpa);
  nid+1;
  if first.id then do;
     difsum=0;
     nid=1;
  end;
  if last.id;
  mean_dif=difsum/(nid-1);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 21:58:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Trend-for-Each-Group-of-Observations/m-p/634912#M188473</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-03-25T21:58:22Z</dc:date>
    </item>
  </channel>
</rss>

