Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Format

Status
Not open for further replies.

proximo20

Technical User
Sep 29, 2009
22
0
0
US
I have column which looks like:

1112
1113
1114
1115
...
...

I need it to look like this:

11/12
11/13
11/14
...
...

Thanks
 
Hi,

See in PDF "SAS Language Reference: Dictionary" in "Chapter 3: Formats" the section on MMDDYYw. format for details.

Code:
data _null_;

  length txtDate $5
         numDate 8
         ;
  /*--  as text - not so nice  */
  txtDate = '0225';
  txtDate = substr(txtDate,1,2) !! '/' !! substr(txtDate,3);
  put '  Brute Force Text: ' txtDate;

  /*--  as numeric date  */
  numDate = '25-FEB-2011'd;
  put ' Full numeric Date: ' numDate YYMMDD10.;
  put 'Short numeric Date: ' numDate MMDDYY5.;

  /*--  to store from number as text:  */
  txtDate = put (numDate, MMDDYY5.);

run;

OUTPUT:
  Brute Force Text: 02/25
 Full numeric Date: 2011-02-25
Short numeric Date: 02/25
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top