Here Date is a set of different dates defined in d_mtcars dataset and I am trying to find the number of days between Date and last_date. But, the values in the days column are missing as output. Please help.
data date_mtcars;
set character_mtcars(drop=prefix);
set d_mtcars;
last_date='29july2017';
days= intck ('day',Date,last_date);
run;
proc print data=date_mtcars;
run;
Other than the date does the data set appear in the correct format?
You need only a 3 character month, you have the full word.
JUL vs JULY
Why do you have 2 SET statements? What are you expecting to happen with those two statements?
I have combined two datasets using two set statements.
Review how to combine data. I suspect that's your first and probably biggest issue.
Beyond to @Reeza's comment, relating to combination of datasets,
you have an error defining a date literal. Change line into:
last_date='29july2017'd;
and you can calculate days between dates just by:
days = date - last_date;
no need to use special function.
data date_mtcars;
set character_mtcars(drop=prefix);
set d_mtcars;
last_date='29july2017'd;
days= intck('day',Date,last_date);
run;
proc print data=date_mtcars;
run;
After defining date as you said, it's showing error again,
Other than the date does the data set appear in the correct format?
You need only a 3 character month, you have the full word.
JUL vs JULY
Assuming that date is actually a SAS date, your problem is likely that you defined:
last_date='29july2017';
when you should have used:
last_date='29july2017'd;
Art, CEO, AnalystFinder.com
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 save with the early bird rate—just $795!
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.