Thursday, October 30, 2008

How to convert a SAS date to a character variable

/***************************************************************************//*
Title: Convert a SAS date to a character variable *// *
*//* Goal: Use the PUT function to create a character variable from *//*
a SAS date. *//* *//***************************************************************************/

data one;
input sasdate :mmddyy6.;
datalines;
010199;
run;

data two;
set one;
chardate=put(sasdate,mmddyy6.);
run;

/* RESULTS */

Obs sasdate chardate
1 14245 010199


Source: ftp://ftp.sas.com/techsup/download/sample/datastep/convertchar.html

2 comments:

Anonymous said...

Fine, but what about a date like 01011999, which there doesn't appear to be a date format for?

sarath said...

you use mmddyy8. format instead of mmddyy6.

Post a Comment

ShareThis