<?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 increase in a variable in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Calculating-an-increase-in-a-variable/m-p/33430#M8087</link>
    <description>Hello Igtea57,&lt;BR /&gt;
&lt;BR /&gt;
It is hard to help you not seeing a sample of your data and not having clear requirements. Anyway, accepting data from the last post I'll try:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data i;&lt;BR /&gt;
input EmployeeID grade pay rank gender $ race $ year ;&lt;BR /&gt;
cards ;&lt;BR /&gt;
1 2 123 4 m c 2007&lt;BR /&gt;
1 3 123 4 m c 2008&lt;BR /&gt;
1 1 123 4 m c 2009&lt;BR /&gt;
2 5 123 4 m c 2007&lt;BR /&gt;
2 3 123 4 m c 2008&lt;BR /&gt;
2 7 123 4 m c 2009&lt;BR /&gt;
;&lt;BR /&gt;
proc sort data=i;&lt;BR /&gt;
  by EmployeeID Year;&lt;BR /&gt;
run;&lt;BR /&gt;
data r;&lt;BR /&gt;
  retain LG;&lt;BR /&gt;
  set i;&lt;BR /&gt;
  if FIRST.EmployeeID then do; inc=0; dec=0; LG=0; end;   &lt;BR /&gt;
  if LG NE 0 then do;&lt;BR /&gt;
    if grade &amp;gt; LG then inc+1;&lt;BR /&gt;
    if grade &amp;lt; LG then dec+1;&lt;BR /&gt;
  end;&lt;BR /&gt;
  LG=grade;&lt;BR /&gt;
  if LAST.EmployeeID;&lt;BR /&gt;
  by EmployeeID;&lt;BR /&gt;
  drop LG;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
    <pubDate>Mon, 21 Mar 2011 14:46:40 GMT</pubDate>
    <dc:creator>SPR</dc:creator>
    <dc:date>2011-03-21T14:46:40Z</dc:date>
    <item>
      <title>Calculating an increase in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculating-an-increase-in-a-variable/m-p/33426#M8083</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I am working with a data set that contains an employee ID, grade, pay, rank, gender, and race for three years, 2007, 2008 and 2009.  I need to end up with the number of promotions (an increase in grade) for each year and am guessing I need to calculate when there is an increase in grade during each year.  I'm just not sure exactly how to do it.  (I sitll have soooo much to learn!) &lt;BR /&gt;
&lt;BR /&gt;
 I feel like an array is the best option, but I am new that subject, so wanted to see what someone else thought?&lt;BR /&gt;
&lt;BR /&gt;
Thank you in advance!</description>
      <pubDate>Fri, 18 Mar 2011 20:01:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculating-an-increase-in-a-variable/m-p/33426#M8083</guid>
      <dc:creator>lgtea57</dc:creator>
      <dc:date>2011-03-18T20:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating an increase in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculating-an-increase-in-a-variable/m-p/33427#M8084</link>
      <description>Hello Igtea57,&lt;BR /&gt;
&lt;BR /&gt;
If only increase in grade is possible then the solution is very simple&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc SQL;&lt;BR /&gt;
  create table r as select&lt;BR /&gt;
  ID, Year, COUNT(distinct Grade) as ng&lt;BR /&gt;
  from i&lt;BR /&gt;
  group by ID, Year&lt;BR /&gt;
;quit; &lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Fri, 18 Mar 2011 20:17:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculating-an-increase-in-a-variable/m-p/33427#M8084</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-03-18T20:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating an increase in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculating-an-increase-in-a-variable/m-p/33428#M8085</link>
      <description>There are other columns that change, pay, grade and rank all change, so I am not sure if this will work.  &lt;BR /&gt;
&lt;BR /&gt;
 I need to calculate the number of increases in grade for each year, as well as the number of decreases in grade for each year.    Any thoughts?</description>
      <pubDate>Sun, 20 Mar 2011 18:57:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculating-an-increase-in-a-variable/m-p/33428#M8085</guid>
      <dc:creator>lgtea57</dc:creator>
      <dc:date>2011-03-20T18:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating an increase in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculating-an-increase-in-a-variable/m-p/33429#M8086</link>
      <description>data one  ;&lt;BR /&gt;
input employeeID grade pay rank gender $ race $ year ;&lt;BR /&gt;
cards ;&lt;BR /&gt;
1 2 123 4 m c 2007&lt;BR /&gt;
1 3 123 4 m c 2008&lt;BR /&gt;
;&lt;BR /&gt;
proc sql ;&lt;BR /&gt;
  create table g_delta as &lt;BR /&gt;
select a.employeeID, a.grade as new_g, b.grade as old_g&lt;BR /&gt;
from one A&lt;BR /&gt;
join one B&lt;BR /&gt;
on a.employeeID = B.employeeID&lt;BR /&gt;
where a.year=2008 &lt;BR /&gt;
and  b.year = 2007&lt;BR /&gt;
and a.grade ne b.grade&lt;BR /&gt;
;&lt;BR /&gt;
quit;</description>
      <pubDate>Sun, 20 Mar 2011 23:27:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculating-an-increase-in-a-variable/m-p/33429#M8086</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-03-20T23:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating an increase in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculating-an-increase-in-a-variable/m-p/33430#M8087</link>
      <description>Hello Igtea57,&lt;BR /&gt;
&lt;BR /&gt;
It is hard to help you not seeing a sample of your data and not having clear requirements. Anyway, accepting data from the last post I'll try:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data i;&lt;BR /&gt;
input EmployeeID grade pay rank gender $ race $ year ;&lt;BR /&gt;
cards ;&lt;BR /&gt;
1 2 123 4 m c 2007&lt;BR /&gt;
1 3 123 4 m c 2008&lt;BR /&gt;
1 1 123 4 m c 2009&lt;BR /&gt;
2 5 123 4 m c 2007&lt;BR /&gt;
2 3 123 4 m c 2008&lt;BR /&gt;
2 7 123 4 m c 2009&lt;BR /&gt;
;&lt;BR /&gt;
proc sort data=i;&lt;BR /&gt;
  by EmployeeID Year;&lt;BR /&gt;
run;&lt;BR /&gt;
data r;&lt;BR /&gt;
  retain LG;&lt;BR /&gt;
  set i;&lt;BR /&gt;
  if FIRST.EmployeeID then do; inc=0; dec=0; LG=0; end;   &lt;BR /&gt;
  if LG NE 0 then do;&lt;BR /&gt;
    if grade &amp;gt; LG then inc+1;&lt;BR /&gt;
    if grade &amp;lt; LG then dec+1;&lt;BR /&gt;
  end;&lt;BR /&gt;
  LG=grade;&lt;BR /&gt;
  if LAST.EmployeeID;&lt;BR /&gt;
  by EmployeeID;&lt;BR /&gt;
  drop LG;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Mon, 21 Mar 2011 14:46:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculating-an-increase-in-a-variable/m-p/33430#M8087</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-03-21T14:46:40Z</dc:date>
    </item>
  </channel>
</rss>

