BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
atulsingh
Obsidian | Level 7

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;
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

View solution in original post

8 REPLIES 8
Reeza
Super User

Why do you have 2 SET statements? What are you expecting to happen with those two statements?

atulsingh
Obsidian | Level 7

I have combined two datasets using two set statements.

atulsingh
Obsidian | Level 7
please help.
Reeza
Super User

Review how to combine data. I suspect that's your first and probably biggest issue.

http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p15jvywi5avt3cn1bee8...

 

Shmuel
Garnet | Level 18

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.

atulsingh
Obsidian | Level 7

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,

 
ERROR: Invalid date/time/datetime constant '29july2017'd.
ERROR 77-185: Invalid number conversion on '29july2017'd.

 

Reeza
Super User

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

art297
Opal | Level 21

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

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 2978 views
  • 0 likes
  • 4 in conversation