DATA Step, Macro, Functions and more

date field

Reply
Super Contributor
Posts: 673

date field

The date format is not consistent across the observations.
the first few rows has 09/18/2009 format and after which some rows will have
Sep-09 format.
How to make the date field consistent like mmddyy10. format?
Super Contributor
Posts: 359

Re: date field

Is this a SASDATE variable or text. It must be text for this to happen. Give us some information on what type of data you have.
Super Contributor
Posts: 673

Re: date field

text.
This is how i get my date field:

SHIP_DATE
09/22/2009
09/18/2009
09/22/2009
09/18/2009
Sep-09
Sep-09
Frequent Contributor
Posts: 102

Re: date field

This will do it.
------------------------------------
data test;
format SHIP_DATE mmddyy10.;
input SHIP_DATE : anydtDTE10.;
cards;
09/22/2009
09/18/2009
09/22/2009
09/18/2009
Sep-09
Sep-09
;
run;
--------------------
Frequent Contributor
Posts: 102

Re: date field

Posted in reply to CurtisMack
If you are still working on translating those Excel spreadsheets, this is probably more what you are looking for.
------------------------------
data test;
length SHIP_DATE $10;
input SHIP_DATE;
cards;
09/22/2009
09/18/2009
09/22/2009
09/18/2009
Sep-09
Sep-09
;
run;
data test2;
set test;
format SHIP_DATE_DT mmddyy10.;
SHIP_DATE_DT = input(SHIP_DATE,anydtDTE10.);
run;
-----------------------------
Super Contributor
Posts: 359

Re: date field

input dateinfo anydtdte21.;
Ask a Question
Discussion stats
  • 5 replies
  • 135 views
  • 0 likes
  • 3 in conversation