LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (August 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 5 Aug 2008 09:23:08 -0700
Reply-To:   "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Subject:   Re: How to keep an earliest date?
Comments:   To: irinfigvam@yahoo.com
In-Reply-To:   A<650988.60976.qm@web51607.mail.re2.yahoo.com>
Content-Type:   text/plain; charset="iso-8859-1"

Hi Irin,

data sample; input ID SRV_DT1 date9. +1 SRV_DT2 date9.; format SRV_DT1 date9. SRV_DT2 date9.; cards; 1 04Nov2005 10Dec2005 2 12Feb2006 01Jan2007 3 03Mar2006 04Apr2005 ; run;

* SAS date is number of days ; * so just use a numeric function ; * to keep the minimum value ; data result1(keep=ID SRV_DTfinal); set sample; SRV_DTfinal = min(SRV_DT1,SRV_DT2); format SRV_DTfinal date9.; run;

* same but as sql ; proc sql; create table result2 as select ID, min(SRV_DT1,SRV_DT2) as SRV_DTfinal format=date9. from sample ; quit;

Hope this is helpful.

Mark Terjeson Senior Programmer Analyst Investment Management & Research Russell Investments

Russell Investments Global Leaders in Multi-Manager Investing

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Irin later Sent: Tuesday, August 05, 2008 9:09 AM To: SAS-L@LISTSERV.UGA.EDU Subject: How to keep an earliest date?

I have a Table Service with the following fields: ID SRV_DT1 SRV_DT2 **************************** 1 o4Nov2005 10Dec2005 2 12Feb2006 01Jan2007 3 03Mar2006 04Apr2005

Proc contents gave the following for SRV_DT # Variable Type Len Format Informat Label 5 SRV_DT Num 8 DATE9. DATE9. SRV_DT

I need: ID SRV_DTfinal **************** 1 o4Nov2005 2 12Feb2006 3 04Apr2005 to keep the earliest of the dates among (SRV_dt1 and SRV_DT2) How can I implement it through either SAS syntax or Proc SQL? Thank you in advance, Irin


Back to: Top of message | Previous page | Main SAS-L page