I've a dataset that has wrong dates created off of a excel drag function. How can I compare and identify the dates that are exactly one day apart in the sequence to alert the team?
Thank you
| ProductID | Date_shipped |
| P3456 | 10/2/2023 |
| R2342 | 10/3/2023 |
| H9875 | 10/4/2023 |
| L5543 | 10/5/2023 |
Use the DIF function.
data want;
set have;
days=dif(date_shipped);
run;
Use the DIF function.
data want;
set have;
days=dif(date_shipped);
run;
Thank you.
DIF function works, but is there any similar function to DIF to use in Proc SQL?
ERROR: The DIF function is not supported in PROC SQL, it is only valid within the DATA step.
I have all my filters in SQL. Just for handling DIF function I have to recreate the whole dataset and order it again.
@Stalk wrote:
Thank you.
DIF function works, but is there any similar function to DIF to use in Proc SQL?
ERROR: The DIF function is not supported in PROC SQL, it is only valid within the DATA step.
I have all my filters in SQL. Just for handling DIF function I have to recreate the whole dataset and order it again.
SQL by its very nature knows nothing about the ORDER of observations so it is a terrible choice to do something like this.
Your second statement makes no sense at all. How are going to create a new VARIABLE without creating a new dataset, whether you use SQL query or a data step?
Note that you can create views using either PROC SQL code or data step code you want to avoid making multiple physical copies of the data.
Do you have other identification information such as a purchase order/bill of lading/ what have you? It would likely be a good idea to only report these one day increments in the case of some group identified as such.
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.