I've got a stored process that has a Proc SQL step that uses several tables. The data from this Proc Sql creates an output that contains several data records per person (not duplicates). These several records per person give data about the persons assigned jobs, including when their assigned jobs end. These people can have multiple assigned jobs (i.e., Jan 1, 2005 to Mar 1, 2005: Teacher, Mar 2, 2005 - Sep. 1 2006, Professor, Sep2, 2006 - sep 3, 2007 - Dean).
In my case, I only want to retrieve a person's last position information. Would I therefore use a Proc Sort after the Proc SQL, or in the Proc SQL itself, group on the person's assigned job's end date, and then use a data step to get the person's assigned job's end date?
Would something like the following pseudocode work?
Proc SQL;
create table step01
....
....
group by assigned job's end date;
Quit;
Proc sort data = step01;
by assigned job's end date;
Data finaloutput;
set step01;
by assigned job's end date;
if first assigned job's end date = 1;
run;
It just seems on the sort and data steps that there is repetition of BY information.... is that the way it has to be, or is there a more efficient way? I got my information from "The Little SAS Book."
And....is there anywhere else I can get information about using FIRST. and LAST.?
Thanks so much in advance.