From: jofo on 1 Mar 2007 09:57 Hello All, I need a little help on a SAS dataset. The data has a text field that is actually a date. Like this. beginning ending 8/11/2001 10/1/2001 12/1/2000 1/22/2001 The field is text. How do a format this field as a date? Seems easy enough, but I can't seem to get it. Thanks.
From: Nat on 1 Mar 2007 10:59 Hi Jofo, This could be one of the ways to look at your problem: data sam1(drop=beginning ending); length beginning ending $10; input beginning ending ; beginning1=input(beginning,mmddyy10.); /* convert character to numeric using appropriate date format */ ending1=input(ending,mmddyy10.); /* convert character to numeric using appropriate date format */ format beginning1 ending1 mmddyy10.; /* format the new variables using the same format */ cards; 8/11/2001 10/1/2001 12/1/2000 1/22/2001 ; Regards, Nat
From: patho on 1 Mar 2007 11:04 Hope this helps if you want to read character data into numeric data, use the input function. I nice link ( personal opinion) to quickly read is http://www.pauldickman.com/teaching/sas/char_to_num.php an example ========== data step; format beginning $10. ending $10.; beginning = '8/11/2001'; ending = '10/1/2001'; output; beginning = '12/1/2000'; ending = '1/22/2001'; output; run; data step2; format date_begin date_end mmddyy10.; set step; date_begin = input(beginning,mmddyy10.); date_end = input(ending,mmddyy10.); run; proc contents data=step2; run; regards, Mark Roosen Sas Consultant On 1 mrt, 15:57, "jofo" <joey.fo...(a)gmail.com> wrote: > Hello All, > > I need a little help on a SAS dataset. The data has a text field that > is actually a date. > > Like this. > > beginning ending > 8/11/2001 10/1/2001 > 12/1/2000 1/22/2001 > > The field is text. > > How do a format this field as a date? > > Seems easy enough, but I can't seem to get it. > > Thanks.
|
Pages: 1 Prev: research question Annual percent change Next: internal source spool file has been truncated |