Hi all,

I'm just wondering if there is a equivalent of SAS's FIRST. and LAST.
variables in R?

For example, suppose this is a snapshot of the data:
	  ClientCode CaseCode       open      close    Important
	1         37       28 2003-07-08 2003-09-02            1
	2         37      310 2003-11-01 2004-09-10            1
	3         37     1562 2007-04-03 2007-07-27            1
	4         38       29 2003-02-28 2007-09-05            1
	5         38      599 2004-07-14 2007-10-31            1

For each client, I want to see that if a case is important (Important =
1), then check its close date and the next open-date for the client.
E.g. for Client 37, I want to get the difference between Case 310's open
date and Case 28's close date, as well as find out whether Case 310 is
"Important".

I know how to get this using SAS's DATA step (with BY statement and
FIRST. variable).  But I'm having trouble finding the equivalent in R.

Any suggestions will be greatly appreciated!

Cheers,

Kevin


Kevin Wang
Senior Adviser, Government Advisory Services
Advisory

KPMG
10 Shelley Street
Sydney  NSW  2000  Australia

Tel 	+61 2 9335 8282
Fax	+61 2 9335 7001
Mob	0404 518 301
kevinwang@kpmg.com.au <mailto:kevinwang@kpmg.com.au > 

kpmg.com.au <http://kpmg.com.au/> 

Best Accounting Firm - BRW Client Choice Awards 2010

Protect the environment: please think before you print




	[[alternative HTML version deleted]]

