Hi currently I've A date formatted like this 20080220 00:00:00... I tried doing a datepart to format it to MMDDYY8. SAS or Excel doesn't see it as date ... How can a data step convert this to a date that can used to query? Thanks again for your assistance
I agree. It depends upon what you are doing and from where. If the value is coming into SAS as a character string, the following might connect the dots:
options datestyle=ymd;
data table_a;
informat dt $20.;
input dt;
cards;
20080220 00:00:00
;
data want;
set table_a;
format want_dt date9.;
want_dt=input(dt,anydtdte8.);
run;
If the time part is irrelevant, anyhow, you could use the anydtdte informat to only read the first 8 digits. e.g.:
options datestyle=ymd;
data have;
informat dt anydtdte8.;
format dt date9.;
input dt;
cards;
20080220 00:00:00
;
%put %sysfunc(putn(%sysfunc(timepart(%sysfunc(DATETIME()))),time8));
The name of my table is Table_A with Date/Time for name of col with 20080220 00:00:00 . With the responses provided how do I connect the dots to format it to mmddyy8. ? And thanks again for your assitances
Is this connecting to another database? There are some issues other than SAS formats that may need addressing if so.
I agree. It depends upon what you are doing and from where. If the value is coming into SAS as a character string, the following might connect the dots:
options datestyle=ymd;
data table_a;
informat dt $20.;
input dt;
cards;
20080220 00:00:00
;
data want;
set table_a;
format want_dt date9.;
want_dt=input(dt,anydtdte8.);
run;
Hi Art,
The name of the table is "Table_A" which you make referance in your recomendation the column that has the 20080220 00:00:00 is name Date/Time in your example where do I make referance to that column ?... Thanks again for your assitance
I referenced the column as having the name dt, thus you would just replace dt with the variable's actual name, and you would change the name want_dt to be the name of the new date variable that you want.
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.