Help using Base SAS procedures

How to convert 01/01/00 to reg date ?

Reply
Regular Contributor
Posts: 240

How to convert 01/01/00 to reg date ?

hi I have a date time field  which I do a date part to convert it to date it works but when I try to join it to another table an bring in the converted date it changes to  01/01/00 on all the dates .... How can I keep date being date?

Super User
Super User
Posts: 7,392

Re: How to convert 01/01/00 to reg date ?

Post your code, at a guess the variables format is still date/time even though you only put a date in it. 

data example_date;

     set have;

     format new_date date9.;

     new_date=datepart(old_date);

run;

Regular Contributor
Posts: 240

Re: How to convert 01/01/00 to reg date ?

TThanks for responding

here is my code

data table;

set table(keep =active acctnumber flm slm datetime state city zip);

format date date9.;

date= datepart (date time);

run;

it works I get my date only but when i try to join to another table it converts to 01/01/00 the table is coming from a sql table don't know if that makes. Difference one more thing I sort my original table after I did the datepart an it change it to 01/01/00 one the on the original table thanks again

Super User
Posts: 17,734

Re: How to convert 01/01/00 to reg date ?

Usually SQL stores dates as date time.

You need to show your code - the merge that's causing the issue.

Regular Contributor
Posts: 240

Re: How to convert 01/01/00 to reg date ?

THe table looks like this

proc sql;

create Table audit as

(

select

A.id,

a.owner,

b.active2,

b.date,

c.active1

from table a, table b, table c

where a.id = b.id

and a.id=c.id

);

quit;

Super User
Posts: 17,734

Re: How to convert 01/01/00 to reg date ?

It appears that Table B has a datetime variable, try using dtdate9. format and see how it appears.

proc sql;

create Table audit as

select

A.id,

a.owner,

b.active2,

b.date format=dtdate9.,

c.active1

from table a, table b, table c

where a.id = b.id

and a.id=c.id

;

quit;

Regular Contributor
Posts: 240

Re: How to convert 01/01/00 to reg date ?

It change date to 31dec1959 to all of them

Regular Contributor
Posts: 240

Re: How to convert 01/01/00 to reg date ?

I Thought I could be slick an convert date to character an than join table dive I just need to match another character date an even after I change it to date character it still change format to 01/01/00

Regular Contributor
Posts: 240

Re: How to convert 01/01/00 to reg date ?

I Think I found the error  in mytable  I have a date time field but when I enter no value in it this date 01/01/00 stored automatically into it

i want to keep the field null where there is no value

i notice that my issue is the same. The col has more blanks than entries since it's the date of deinstalled  an where there is no date it defaults to 0/01/00 I would like to have it empty or null

Ask a Question
Discussion stats
  • 8 replies
  • 337 views
  • 3 likes
  • 3 in conversation