Date: Mon, 23 Feb 2009 06:04:31 -0500
Reply-To: Nathaniel.Wooding@DOM.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Nat Wooding <Nathaniel.Wooding@DOM.COM>
Subject: Re: URGENT: concatenating SAS datetime parts
In-Reply-To: <817ab785-da78-4124-b84a-e5bddee19111@f17g2000vbf.googlegroups.com>
Content-Type: text/plain; charset="US-ASCII"
Gergard fired off his reply before I finished typing mine. I put the
compress in a second line just to make things easier to read.
%let Time = 10:24:01 ;
data _null_;
hdr='000001'|| 'UH01' || 'S38500000' || %sysfunc(date(),year4.)
|| %sysfunc(date(),Month2.) || %sysfunc(date(),Day2.)
|| %scan(&TIME.,1,:) || %scan(&TIME.,2,:) ||
%scan(&TIME.,3,:) ||'US01' ;
hdr = compress( hdr );
call symput('hdr',hdr);
put hdr= ;
** to make things a bit simpler: ;
Time = timepart( date() );
hdr1 = '000001'|| 'UH01' || 'S38500000' || Put( date(), yymmdd8. ) ||
put( Time , Time.)
||'US01' ;
hdr1 = compress( hdr1 , ' :-');* get rid of blanks as well as the
seperators in the time value.;
put hdr1=;
run;
Nat Wooding
Environmental Specialist III
Dominion, Environmental Biology
4111 Castlewood Rd
Richmond, VA 23234
Phone:804-271-5313, Fax: 804-271-2977
chumba
<vikas.dharamsatt
u@GMAIL.COM> To
Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU
Discussion" cc
<SAS-L@LISTSERV.U
GA.EDU> Subject
URGENT: concatenating SAS datetime
parts
02/23/2009 05:27
AM
Please respond to
chumba
<vikas.dharamsatt
u@GMAIL.COM>
Hi All,
This is the code I am trying,
data _null_;
hdr='000001'||trim(left('UH01'))||trim(left('S38500000'))||trim(left
(%sysfunc(date(),year4.)))||left(%sysfunc(date
(),Month2.))||left(%sysfunc(date(),Day2.))||left(%scan(&TIME.,
1,:))||left(%scan(&TIME.,2,:))||
left(%scan(&TIME.,3,:))||trim(left('US01')) ;
call symput('hdr',hdr);
run;
and this is the result I am getting,
000001UH01S3850000020092 23 4 22
12 US01
I dont want any spaces between the date and time values and also I
dont want to trim any leading zeros
in front of month, date, hour, min and sec values.
Can somone please help me with this it is kind of urgent.
Thanks a lot.
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.
|