BookmarkSubscribeRSS Feed
lgtea57
Calcite | Level 5
Hello,

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!)

I feel like an array is the best option, but I am new that subject, so wanted to see what someone else thought?

Thank you in advance!
4 REPLIES 4
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello Igtea57,

If only increase in grade is possible then the solution is very simple
[pre]
proc SQL;
create table r as select
ID, Year, COUNT(distinct Grade) as ng
from i
group by ID, Year
;quit;
[/pre]
Sincerely,
SPR
lgtea57
Calcite | Level 5
There are other columns that change, pay, grade and rank all change, so I am not sure if this will work.

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?
Peter_C
Rhodochrosite | Level 12
data one ;
input employeeID grade pay rank gender $ race $ year ;
cards ;
1 2 123 4 m c 2007
1 3 123 4 m c 2008
;
proc sql ;
create table g_delta as
select a.employeeID, a.grade as new_g, b.grade as old_g
from one A
join one B
on a.employeeID = B.employeeID
where a.year=2008
and b.year = 2007
and a.grade ne b.grade
;
quit;
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello Igtea57,

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:
[pre]
data i;
input EmployeeID grade pay rank gender $ race $ year ;
cards ;
1 2 123 4 m c 2007
1 3 123 4 m c 2008
1 1 123 4 m c 2009
2 5 123 4 m c 2007
2 3 123 4 m c 2008
2 7 123 4 m c 2009
;
proc sort data=i;
by EmployeeID Year;
run;
data r;
retain LG;
set i;
if FIRST.EmployeeID then do; inc=0; dec=0; LG=0; end;
if LG NE 0 then do;
if grade > LG then inc+1;
if grade < LG then dec+1;
end;
LG=grade;
if LAST.EmployeeID;
by EmployeeID;
drop LG;
run;
[/pre]
Sincerely,
SPR

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1447 views
  • 0 likes
  • 3 in conversation