DATA Step, Macro, Functions and more

Date format

Reply
Occasional Contributor
Posts: 8

Date format

Dear SAS users

 

I have a variable "Birth_date" with dates of birth. The variable containts numbers between 14316 and 36329. As far as I know the SAS date of birth format counts from the year 1960 so that jan 1st 1960 is "1" and so forth.

 

If I do a proc freq with a date9. format I get dates between year 2011 and year 2052. That doesn't quite make sense since the data should be covering current employees from ages at maybe 16 and up. So I would expect dates between maybe year 1940 and year 2000 or something like that:

 

proc freq data =NEW.Samlet;

format Birth_date date9.;

table Birth_date;

run;

 

Am I doing something wrong or does my data simply contain nonsense?

 

Kind regards,

Jacob

Super User
Super User
Posts: 9,227

Re: Date format

Where do you get those numbers from?  14316=13MAR1999?

Did you get the data from Excel, if so Excel holds date values from a different base date so the number is different.

Occasional Contributor
Posts: 8

Re: Date format

[ Edited ]

Dear RW9

 

The data comes from an employee database and we use SAS primarily so therefore I was expecting the numbers to express a SAS-format. I thought that maybe the explanation was that more than one baseline-format existed in SAS, such as if a 1900-baseline was also sometimes used, then maybe that would explain the distribution.

 

Kind regards,

Jacob

Super User
Super User
Posts: 9,227

Re: Date format

Well there is:

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000197881.htm

 

However you need to know what those numbers actually refer to.  I would also be careful about changing the option as it may affect other data's representation in the same session.

Occasional Contributor
Posts: 8

Re: Date format

Thanks

Super User
Posts: 13,084

Re: Date format


Jbraun wrote:

Dear SAS users

 

I have a variable "Birth_date" with dates of birth. The variable containts numbers between 14316 and 36329. As far as I know the SAS date of birth format counts from the year 1960 so that jan 1st 1960 is "1" and so forth.

 


You might be interested to know that those example numbers will be 3/12/1939 and 6/18/1999 if treated as EXCEL date values which uses 1/1/1900 as it's base date. Perhaps the data base imported data from Excel but did not use or associate a date format with them, or the date format did not carry over from export or however you moved the data into SAS.

 

 

Occasional Contributor
Posts: 8

Re: Date format

@ballardwthanks, that age span would definitely make a lot more sense. I will of course look for documentation to make sure.

Ask a Question
Discussion stats
  • 6 replies
  • 150 views
  • 1 like
  • 3 in conversation