data want;
set have;
day=INPUT(SUBSTR(left(opendate),1,10),yymmdd10.);
format day mmddyy10.;
run;
INPUT() converts and you can try ANYDTDTM. for a datetime
@Gil_ wrote:
I have a col classified character $31
Here is example.
2018-04-03:11:26:45:573000000
I use
Data test;
Set test;
Day=substr(left(opendate),1,10);
Format day mmddyy10.;
Run;
I used that b4 the input to convert it.
You didn't apply the format correctly and since it's a date time, it creates a date time. You can display it as a date using DTDDMMYY10 or DTDATE9 or convert it using DATEPART() to get the date portion.
@Gil_ wrote:
It converted to number here is code
Data test;
Set test;
DayTime = input(day,ANYDTDTM.);
date = datepart(dayTime);
FORMAT DAY dtdate9. date ddmmyy10.;
RUN;
data want;
set have;
day=INPUT(SUBSTR(left(opendate),1,10),yymmdd10.);
format day mmddyy10.;
run;
Even simpler (the FORMAT statement is still necessary):
day = input(opendate, yymmdd10.);
That assumes your character variable OPENDATE is left-hand-justified.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.