DATA Step, Macro, Functions and more

EG or CODE- change dob format ( from text to date) , calculate age

Reply
N/A
Posts: 0

EG or CODE- change dob format ( from text to date) , calculate age

How can I change date format from text to date :
then create the variable called age to calculate the account age.

How to in Enterprise Guide ?
How to in code ?
Respected Advisor
Posts: 4,173

Re: EG or CODE- change dob format ( from text to date) , calculate age

Posted in reply to deleted_user
Hi

To convert a date string to a number representing a SAS date use a informat. Which informat to use depends on the form of the date string you have.

You could try:
SASDateVar=input(DateStringVar,anydtdte.);

Age in days would then be:
Age=today() - SASDateVar;

If you have to calculate the age based on a year with 360 days then look up function DATDIF() in the Base SAS documentation.

HTH
Patrick
N/A
Posts: 0

Re: EG or CODE- change dob format ( from text to date) , calculate age

Thank you !! that works perfect
Ask a Question
Discussion stats
  • 2 replies
  • 138 views
  • 0 likes
  • 2 in conversation