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
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.
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
And please post your questions only once.
Sure
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).
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.
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 25. Read more here about why you should contribute and what is in it for you!
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.