Date: Wed, 20 Feb 2002 13:21:36 +0100
Reply-To: Peter Crawford <peter.crawford@DB.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Peter Crawford <peter.crawford@DB.COM>
Subject: Re: 2 Digit date/year from ddmmmyyyy
Content-type: text/plain; charset=iso-8859-1
Hi Venky
I know it's nice to see the new date-type format directives, but
wouldn't the old format yymmdd2. do for year?
%put %sysfunc( date(), yymmdd2 );
returns
02
even in v6.12 ts020 !
Regards
Peter
data test_date ;
format month day z2. year yymmdd2. ;
month = month(&report_date) ;
day = day(&report_date) ;
year = &report_date ;
put (_all_)(+1 =);
run;
sends this line to my log
month=02 day=11 year=02
Datum: 20/02/2002 12:06
An: SAS-L@LISTSERV.UGA.EDU
Antwort an: "Chakravarthy, Venky" <Venky.Chakravarthy@PFIZER.COM>
Betreff: Re: 2 Digit date/year from ddmmmyyyy
Nachrichtentext:
Guinness,
You have already received a solution that addresses the 2 digit format for
the month. For formatting the year to two digits, use one of the latest
offerings from SAS - DIRECTIVES in the Picture Format :
%let report_date = '11FEB2002'd;
proc format ;
picture myyear low - high = '%0y'
( datatype = date ) ;
run ;
data test_date ;
format month day z2. year myyear. ;
month = month(&report_date) ;
day = day(&report_date) ;
year = &report_date ;
run;
options nocenter ;
proc print ;
run ;
Obs month day year
1 02 11 02
Kind Regards,
Venky
#****************************************#
# E-mail: venky.chakravarthy@pfizer.com #
# swovcc@hotmail.com #
# Phone: (734) 622-1963 #
#****************************************#
-----Original Message-----
From: guinness@TGAFFNEY.ORG [mailto:guinness@TGAFFNEY.ORG]
Sent: Tuesday, February 19, 2002 5:56 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: 2 Digit date/year from ddmmmyyyy
Greetings-
I am new to SAS, so excuse the basic nature of this question...
I have a date: %let report_date = '11FEB2002'd;
From this date I would like to extract the 2 digit year and 2 digit month.
Using the following:
data test_date;
month = month(&report_date);
day = day(&report_date);
year = year(&report_date);
run;
I can only extract a 1 digit month (2) and a 4 digit year (2002). Is it
possible, using the '11FEB2002'd format to get a 2 digit month (02) and year
(02)?
Thanks!
--
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.