11-28-2012 05:22 PM
I have a column of type Character that holds the date in the following format
data looks something like this:
2012-1-01 (first of jan)
2012-2-01 (1st of Feb and so on)
May I know how to convert it into a date format?
11-28-2012 05:34 PM
Take advantage of the formats available in SAS :
date = "2012-1-01";
date = "2012-2-01";
numDate = input (date, yymmdd12.);
format numDate yymmdd10.;
proc print; run;
11-28-2012 05:38 PM
If in an existing SAS dataset the variable can't be "converted" from string to numeric (date and such are numeric). A new variable from your existing variable can be added using
Sasdate = input(yourstringvariablename, anydtdte12.);
/* you probably want to assign a display format to make the values understandable */
format sasdate mmddyy10.; /* as one example*/
If you are reading the variable from a file you can apply the informat when read by using something like:
Informat datevaraible anydtdte12; before the input statement.
11-29-2012 04:36 AM
If you are really stuck with delivering something on the basis of this I shall suggest to export this column to excel, make your desired changes and import.