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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.