Hello team,
I need to find out if DateofService that are within 30 days of the dischargedate.
I appreciate your help.
Regards,
blue & blue
If they both contain DATE values then just test is the absolute value of the difference is less than or equal to 30.
Make sure to protect against missing values and SAS will consider a missing value as less than any actual number.
if -1 < abs(DateofService-dischargedate) <= 30 then .....
Hello Tom,
Thanks for your response.
why should I use abs?
if dateofservice is less than discharge date, then that is ok. We want to find out those records when they had a visit within 30 days after their discharge.
if we use abs, then we can’t find out within 30 days after thr discharge date.
can’t we use datedif?
how should I guard against missing values? If discaregedate or dateofservice ne.?
yes both values are dates. I think if the result is positive, then dos has occurred after discharge date. Then, I need to find out if it is between 0 to 30 days.
regards
blue & blue
Just swap your variables then:
if 1 <= (dischargedate - DateofService) <= 30;
Not sure what happens if both happen on the same day. Do you want to count those? If so change the 1 to 0.
"Why don’t I say if difference is > 0 and <= 30?"
You'll get the same results as in my logic.
"And should I find the difference first and then bring if?"
Up to you, which ever way is best for you. There is no right or wrong answer here.
Because you asked for "within 30 days", which would imply plus or minus 30 days.
All your questions regarding date values are answered here:
Working with Dates in the SAS System
Studying these documents will make most of your date-related posts here unnecessary.
Hello Kurt,
What you have directed me are links after links. If I want to get that route, I would be lost and each day, I need to start working in a new company. Obviously, reading is essential part of gaining education, I always read and search and then I post my question here.
I clicked on the links then other links came up and then till seven layers deep that I forgot what I wanted.
Anyway, thank you for sending me the direction that I go back and read them after I deliver my projects. I have short deadlines.
Respectfully,
Blue & Blue
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.