From: Tom Abernathy on 21 Feb 2010 10:30 Abebe - With this structure it looks like the last date should be the maximum date. lastdate=max(of date1-date4); - Tom On Feb 21, 9:46 am, abebegashaw...(a)GMAIL.COM (Abebe Gashaw) wrote: > Hi friends. > > I have a dataset which contains records with variables with contents and > missing values as follow: > > Data Test1; > > Input Name $ Action1 $ data1 $ Action2 $ Date2 $ Action3 $ data3 $ action4 > $ date4$; > > Cards; > > Name1 read 02Feb10 write 03Feb10 > > name2 read 01Feb10 write 05Feb10 walk 10Feb10 Jump 12Feb10 > > Name3 read 03Feb10 eat 08Feb10 Run 13fEB10 ; > > Run; > > In order to find the duration; I need to know the last day so that I will > subtract last data minus data1. > > Since there could be some missing variable such as date3 for NAME1 or Data4 > for NAME3, I am having problem finding or identifying the last non-missing > date for each record. > > Can someone help me doing that please? > > Regards, > > Abebe
From: Nathaniel Wooding on 21 Feb 2010 11:45 Try the following. And, thank you for providing sample code. I did take the liberty of making the names of the date variables uniform. Some were spelled "Data". Nat Wooding Data Test1; infile cards missover; informat Name $5. Action1 $4. date1 DATE. Action2 $5. Date2 DATE. Action3 $5. date3 DATE. action4 $5. date4 DATE.; input Name Action1 date1 Action2 Date2 Action3 date3 action4 date4 ; ARRAY Dates Date4 date3 date2 date1 ;* note that the elements are specified in reverse order ; Do _I_ = 1 to dim(dates) ;* check from right to left; if Dates(_I_) gt . then do; * If we have a value of date, then we are done; Duration = Dates(_I_) - Date1; leave; end; end; Format Date: mmddyy10.; Cards; Name1 read 02Feb10 write 03Feb10 name2 read 01Feb10 write 05Feb10 walk 10Feb10 Jump 12Feb10 Name3 read 03Feb10 eat 08Feb10 Run 13fEB10 Run; proc print; run; -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of Abebe Gashaw Sent: Sunday, February 21, 2010 9:46 AM To: SAS-L(a)LISTSERV.UGA.EDU Subject: How to get the last non-missing variable value Hi friends. I have a dataset which contains records with variables with contents and missing values as follow: Data Test1; Input Name $ Action1 $ data1 $ Action2 $ Date2 $ Action3 $ data3 $ action4 $ date4$; Cards; Name1 read 02Feb10 write 03Feb10 name2 read 01Feb10 write 05Feb10 walk 10Feb10 Jump 12Feb10 Name3 read 03Feb10 eat 08Feb10 Run 13fEB10 ; Run; In order to find the duration; I need to know the last day so that I will subtract last data minus data1. Since there could be some missing variable such as date3 for NAME1 or Data4 for NAME3, I am having problem finding or identifying the last non-missing date for each record. Can someone help me doing that please? Regards, Abebe CONFIDENTIALITY NOTICE: This electronic message contains information which may be legally confidential and or privileged and does not in any case represent a firm ENERGY COMMODITY bid or offer relating thereto which binds the sender without an additional express written confirmation to that effect. The information is intended solely for the individual or entity named above and access by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution, or use of the contents of this information is prohibited and may be unlawful. If you have received this electronic transmission in error, please reply immediately to the sender that you have received the message in error, and delete it. Thank you.
|
Pages: 1 Prev: How to get the last non-missing variable value Next: Jonckheere test |