LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2002, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 20 Feb 2002 07:27:40 -0500
Reply-To:     "Chakravarthy, Venky" <Venky.Chakravarthy@PFIZER.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Chakravarthy, Venky" <Venky.Chakravarthy@PFIZER.COM>
Subject:      Re: 2 Digit date/year from ddmmmyyyy
Comments: To: "guinness@TGAFFNEY.ORG" <guinness@TGAFFNEY.ORG>
Content-Type: text/plain; charset="iso-8859-1"

Guiness,

In addition to my earlier solution, the available YEAR format can also be used. The default width is 4, meaning a 4 digit year will print. However, the range of available widths begins at 2. Hence, the solution can be simplified to :

%let report_date = '11FEB2002'd;

data test_date ; format month day z2. year year2. ; month = month(&report_date) ; day = day(&report_date) ; year = &report_date ; run;

Although, the DAY and MONTH formats are also available, they do not appear to print with leading zeroes for single digit months and days.

Kind Regards,

Venky #****************************************# # E-mail: venky.chakravarthy@pfizer.com # # swovcc@hotmail.com # # Phone: (734) 622-1963 # #****************************************#

-----Original Message----- From: Chakravarthy, Venky Sent: Wednesday, February 20, 2002 7:06 AM To: 'guinness@TGAFFNEY.ORG'; SAS-L@LISTSERV.UGA.EDU Subject: RE: 2 Digit date/year from ddmmmyyyy

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!


Back to: Top of message | Previous page | Main SAS-L page