BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sanjay1
Obsidian | Level 7


Hi Experts,

 

I am tryng to create a date variable "Conversion" in datset test, but it is taking the value as 10Jan1960.


I am not sure what am I missing. Please help

 

data a;
input emp_name$ Convr ;
attrib Convr informat=date9. format=date9.;
datalines;
Avinash 17Jul2018
Rajesh 17Jul2018
;
run;

 

 


data test;
set a;
attrib Conversion informat=date9. format=date9.;
Conversion = (today()-Convr);
run;

 

 

Thanks,

Sanjay

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

CONVERSION isn't a date.  It's a difference between two dates.  It's not appropriate to display it in a date format.  Just remove the ATTRIB statement for CONVERSION.

View solution in original post

5 REPLIES 5
sanjay1
Obsidian | Level 7


Hi Experts,

 

I am tryng to create a date variable "Conversion" in datset test, but it is taking the value as 10Jan1960.
Not sure what am I missing.  I am using SAS 9.4. Please help

 

data a;
input emp_name$ Convr ;
attrib Convr informat=date9. format=date9.;
datalines;
Avinash 17Jul2018
Rajesh 17Jul2018
;
run;

 


data test;
set a;
attrib Conversion informat=date9. format=date9.;
Conversion = (today()-Convr);
run;

 

Thanks,

Sanjay

sanjay1
Obsidian | Level 7

Sure

Kurt_Bremser
Super User

Works as documented.

You subtract a date that is 10 days before now from now, so you get a value of 10. When you format that as a date, you get 10 days from the SAS base point for dates (01jan1960).

Astounding
PROC Star

CONVERSION isn't a date.  It's a difference between two dates.  It's not appropriate to display it in a date format.  Just remove the ATTRIB statement for CONVERSION.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1845 views
  • 0 likes
  • 3 in conversation