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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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