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.
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!
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.
Ready to level-up your skills? Choose your own adventure.