|
Hi Tony,
I do not directly see another, quicker way. But I see that your series of IF
statements with associated OUTPUT statements cause the later periods to
involve *all* previous periods as well, not only the data for the periods
themselves. P2 involves P1 completely, P3 involves P1 and P2, P4 involves
P1, P2 and P3, and so on. The very last period would involve the complete
original set of observations. I do not know whether this is what you intend.
If you only want data for the periods, after the start date, but before the
end date, you should change all IFs, except the first one, into ELSE IFs.
Regards - Jim.
--
Y. (Jim) Groeneveld, MSc IMRO TRAMARKO tel. +31 412 407 070
senior statist./data man. P.O. Box 1 fax. +31 412 407 080
J.Groeneveld@ITGroups.com 5350 AA BERGHEM, NL www.imrotramarko.com
Computers aren't there to be kept busy, but to keep us busy.
Notice of confidentiality: this e-mail may contain confidential information
intended for the addressed recipient only.
If you have received this e-mail in error please delete this e-mail and
please notify the sender so that proper delivery
can be arranged.
> -----Original Message-----
> From: Gallegly, Tony [SMTP:Tony.Gallegly@TRICON-YUM.COM]
> Sent: Saturday, May 18, 2002 4:39 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Please Help with Efficient Alternative Code
>
> I need to generate a list of individuals that were employed during
> different time periods. I have two tables that contain the necessary
> information.
>
> 1. Employee Work History: The work history table stores changes to an
> employees work status. It can be assumed that an employee is employed as
> long as the most recent row is a row that can be associated with active
> employment.
>
> For Example:
> Name Effective Date Action Cost Center
> John S 02/19/2000 Hire 123
> John S 06/25/2000 Transfer 345
> John S 11/05/2000 Promotion 456
> John S 01/15/2001 Termination 456
>
> 2. Calendar table: The time periods are consecutive 28 day intervals.
> For Example
> Period Beginning Date End Date
> 1 01/01/2000 01/29/2000
> 2 01/30/2000 02/27/2000
> 3 02/28/2000 02/27/2000
>
> John Smith would be counted as an active employee from 2/19/2000 to
> 1/15/2001 so his name would appear in each period.
>
> I am currently creating a separate data set for each time period keeping
> only employee's whose max effective date is prior to the end date of the
> period and the action associated with that effective date is considered an
> action for an active employee. The code below is crude and very CPU
> intensive since I have over 30 periods. Can you please advise on a more
> efficient way to program this.
>
> DATA P1 P2 P3 P4;
> SET JOB;
> IF EFFDATE < MDY(01,20,2000) THEN OUTPUT P1;
> IF EFFDATE < MDY(02,17,2000) THEN OUTPUT P2;
> IF EFFDATE < MDY(03,16,2000) THEN OUTPUT P3;
> IF EFFDATE < MDY(04,13,2000) THEN OUTPUT P4;
>
> PROC SORT DATA = P1; BY EMPLID DESCENDING EFFDATE;
> PROC SORT DATA = P2; BY EMPLID DESCENDING EFFDATE;
> PROC SORT DATA = P3; BY EMPLID DESCENDING EFFDATE;
> PROC SORT DATA = P4; BY EMPLID DESCENDING EFFDATE;
>
> DATA P1; SET P1; BY EMPLID; IF FIRST.EMPLID;
> PERIOD = '200001';
> DATA P2; SET P2; BY EMPLID; IF FIRST.EMPLID;
> PERIOD = '200002';
> DATA P3; SET P3; BY EMPLID; IF FIRST.EMPLID;
> PERIOD = '200003';
> DATA P4; SET P4; BY EMPLID; IF FIRST.EMPLID;
> PERIOD = '200004';
>
> Thanks
> Tony Gallegly
>
> DISCLAIMER:
> This communication is confidential and may be legally privileged. If you
> are not the intended recipient, (i) please do not read or disclose to
> others, (ii) please notify the sender by reply mail, and (iii) please
> delete this communication from your system. Failure to follow this process
> may be unlawful. Thank you for your cooperation.
|