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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Format of an Imported Variable 1

Status
Not open for further replies.

smalek

Programmer
Jan 15, 2009
28
CA
Good Day to all you SAS users,
I would like some advice on a problem with SAS. I am importing an ACCESS DB with specific dates into SAS. Unfortunately, the field is coming over as date/time format. I would like to convert it to date only. I tried a number of manipulations (substr, format, scan) but with no luck.

Input data is imported in following format :
30OCT2003:00:00:00
04APR2003:00:00:00
25MAR2003:00:00:00
17JUN2003:00:00:00
etc.

Desired output:
30102003
04042003
25032003
17062003

Any feedback is much appreciated.
Thanks
 
Here is a quick sample of a way to format the data.

Code:
data have;
ex_datetime = '30OCT2003:00:00:00'dt;

ex_date = put(datepart(ex_datetime),ddmmyyn8.);
run;

Use the datepart function to remove the time part of the date. If you don't use the datepart function on a datetime variable, I think you end up with an erroneous value when you convert it to ddmmyy.

Hope this helps
Dave
 
dblan, thanks for your valuable reply. It worked like a charm
Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top