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
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.