From: "data _null_," on 26 Nov 2007 22:21 You could make it easier with a picture format. proc format; picture ts other='%Y-%0m-%0d %0H:%0M' (datatype=datetime); run; data _null_; x = datetime(); put x=; format x ts.; run; On Nov 26, 2007 7:32 PM, LV Subbu <lvsubboo(a)gmail.com> wrote: > Hi, Thanks for your inputs. > > I actually wanted to use date parameters in WHERE condition of an > SQL-passthru query > which expects datetime constant to be passed as {ts '2006-01-12 12:24'} > > I did something like this.. > > %let etl_load_from_dttm=12-DEC-2006:12:24:00 ; > > %let etl_load_from_dttm_odbc=%bquote({ts > '%sysfunc(tranwrd(%sysfunc(putn(%sysfunc(inputn(&etl_load_from_dttm, > datetime21.)),is8601dt.)),T,%str( )))'}); > > > > > On 11/26/07, data _null_, <datanull(a)gmail.com> wrote: > > When the SAS date time values is written out in any format that could > > probably be considered ASCII Date time. > > The IS8601dt format produces result very similar to the input. There > > may be a format that produces an exact match but I don't know it. You > > can format SAS dates and date times any way you like using proc format > > PICTURE combined with the directives for dates and times. > > > > 1 data _null_; > > 2 input ymddttm $16.; > > 3 sasDTTM = input(ymddttm,ymddttm.); > > 4 put (_all_)(=); > > 5 format sas: is8601dt.; > > 6 list; > > 7 cards; > > > > ymddttm=2006-01-12 12:24 sasDTTM=2006-01-12T12:24:00 > > RULE: > ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+- > > 8 2006-01-12 12:24 > > ymddttm=2006-01-12 12:25 sasDTTM=2006-01-12T12:25:00 > > 9 2006-01-12 12:25 > > > > > > On Nov 25, 2007 12:56 AM, LV Subbu <lvsubboo(a)gmail.com> wrote: > > > Hi, is there an equivalent format to convert SASDateTime->ASCII > DateTime? > > > > > > > > > > > > > > > On 11/23/07, data _null_, <datanull(a)gmail.com> wrote: > > > > 150 data _null_; > > > > 151 input ymddttm $16.; > > > > 152 sasDTTM = input(ymddttm,ymddttm.); > > > > 153 put (_all_)(=); > > > > 154 format sas: datetime13.; > > > > 155 cards; > > > > > > > > ymddttm=2006-01-12 12:24 sasDTTM=12JAN06:12:24 > > > > ymddttm=2006-01-12 12:25 sasDTTM=12JAN06:12:25 > > > > > > > > > > > > This assumes that the datepart is YYYY-MM-DD. > > > > > > > > > > > > On Nov 22, 2007 10:17 AM, Li,Qian [Ontario] <Qian.Li(a)ec.gc.ca > wrote: > > > > > Hello everyone, > > > > > > > > > > I have a question regarding converting ASCII data_time into SAS > format. > > > > > For example, the format in ASCII file is: > > > > > 2006-01-12 12:24 > > > > > 2006-01-12 12:25 > > > > > ... > > > > > , with 1-minute interval. > > > > > > > > > > I have now read it as Character in SAS dataset. Could anyone give me > a > > > > > hint as to the best way to convert it to SAS Datetime? > > > > > > > > > > Many thanks. > > > > > > > > > > Julie > > > > > > > > > > > > > > > > > > >
From: "Howard Schreier <hs AT dc-sug DOT org>" on 27 Nov 2007 08:56
On Mon, 26 Nov 2007 21:21:55 -0600, data _null_, <datanull(a)GMAIL.COM> wrote: >You could make it easier with a picture format. > >proc format; > picture ts other='%Y-%0m-%0d %0H:%0M' (datatype=datetime); The exact specification corresponds to picture ts other='{ts ''%Y-%0m-%0d %0H:%0M''}' (datatype=datetime); > run; >data _null_; > x = datetime(); > put x=; > format x ts.; > run; > > >On Nov 26, 2007 7:32 PM, LV Subbu <lvsubboo(a)gmail.com> wrote: >> Hi, Thanks for your inputs. >> >> I actually wanted to use date parameters in WHERE condition of an >> SQL-passthru query >> which expects datetime constant to be passed as {ts '2006-01-12 12:24'} >> >> I did something like this.. >> >> %let etl_load_from_dttm=12-DEC-2006:12:24:00 ; >> >> %let etl_load_from_dttm_odbc=%bquote({ts >> '%sysfunc(tranwrd(%sysfunc(putn(%sysfunc(inputn(&etl_load_from_dttm, >> datetime21.)),is8601dt.)),T,%str( )))'}); >> >> >> >> >> On 11/26/07, data _null_, <datanull(a)gmail.com> wrote: >> > When the SAS date time values is written out in any format that could >> > probably be considered ASCII Date time. >> > The IS8601dt format produces result very similar to the input. There >> > may be a format that produces an exact match but I don't know it. You >> > can format SAS dates and date times any way you like using proc format >> > PICTURE combined with the directives for dates and times. >> > >> > 1 data _null_; >> > 2 input ymddttm $16.; >> > 3 sasDTTM = input(ymddttm,ymddttm.); >> > 4 put (_all_)(=); >> > 5 format sas: is8601dt.; >> > 6 list; >> > 7 cards; >> > >> > ymddttm=2006-01-12 12:24 sasDTTM=2006-01-12T12:24:00 >> > RULE: >> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+- >> > 8 2006-01-12 12:24 >> > ymddttm=2006-01-12 12:25 sasDTTM=2006-01-12T12:25:00 >> > 9 2006-01-12 12:25 >> > >> > >> > On Nov 25, 2007 12:56 AM, LV Subbu <lvsubboo(a)gmail.com> wrote: >> > > Hi, is there an equivalent format to convert SASDateTime->ASCII >> DateTime? >> > > >> > > >> > > >> > > >> > > On 11/23/07, data _null_, <datanull(a)gmail.com> wrote: >> > > > 150 data _null_; >> > > > 151 input ymddttm $16.; >> > > > 152 sasDTTM = input(ymddttm,ymddttm.); >> > > > 153 put (_all_)(=); >> > > > 154 format sas: datetime13.; >> > > > 155 cards; >> > > > >> > > > ymddttm=2006-01-12 12:24 sasDTTM=12JAN06:12:24 >> > > > ymddttm=2006-01-12 12:25 sasDTTM=12JAN06:12:25 >> > > > >> > > > >> > > > This assumes that the datepart is YYYY-MM-DD. >> > > > >> > > > >> > > > On Nov 22, 2007 10:17 AM, Li,Qian [Ontario] <Qian.Li(a)ec.gc.ca > wrote: >> > > > > Hello everyone, >> > > > > >> > > > > I have a question regarding converting ASCII data_time into SAS >> format. >> > > > > For example, the format in ASCII file is: >> > > > > 2006-01-12 12:24 >> > > > > 2006-01-12 12:25 >> > > > > ... >> > > > > , with 1-minute interval. >> > > > > >> > > > > I have now read it as Character in SAS dataset. Could anyone give me >> a >> > > > > hint as to the best way to convert it to SAS Datetime? >> > > > > >> > > > > Many thanks. >> > > > > >> > > > > Julie >> > > > > >> > > > >> > > >> > > >> > >> >> |