date difference for time lag

Posted on 2011-10-17
Last Modified: 2013-11-16
I have two dates MailedToCust, Incident Date both in yymmdd10. format i want to datediff or time lag
sumting like this Calculated:  DateDiff (MailedToCust, Incident Date)
Question by:sam2929
    LVL 14

    Expert Comment

    by:Aloysius Low
    if both are dates (as i imply from your post), then it's simply date1 - date2 and format the column as best.

    data [output];
      set [input];
      date_diff = MailedToCust - IncidentDate;
      format date_diff best.;
    LVL 11

    Expert Comment


    Iowa's result will work - but for a more general solution - SAS uses a function called INTCK to calculate differences in times. The nice thing, is one can calculate other time periods:

    For instance ; INTCK("Month", Date1, Date2) calculates the difference in months between Date1 and Date2 by months.  The SAS help is very good with the descriptions on this one.

    Author Comment

    Does INTCK have DAY function too?
     INTCK("Day", Date1, Date2)
    LVL 11

    Accepted Solution


    Yes it does...

    Here are some of the options:

    (For Time variables)
    SECOND - each second
    MINUTE - each minute
    HOUR - each hour

    (For Date variables)
    DAY - each day
    WEEKDAY - each weekday (Monday through Friday by default)
    WEEK - each Sunday
    TENDAY - the First, Eleventh, and Twenty-first of each month
    SEMIMONTH - the first and sixteenth of each month
    MONTH - the first of each month
    QTR - the first of January, April, July, and October
    SEMIYEAR - the first of January and July
    YEAR - the first of January

    (For DateTime variables)
    DTDAY - each day
    DTWEEKDAY - each weekday (Monday through Friday by default)
    DTWEEK - each Sunday
    DTTENDAY - the First, Eleventh, and Twenty-first of each month
    DTSEMIMONTH - the first and sixteenth of each month
    DTMONTH - the first of each month
    DTQTR - the first of January, April, July, and October
    DTSEMIYEAR - the first of January and July
    DTYEAR - the first of January

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Introduction If you are not already aware of what you could use a table with sequential integer values for in SQL, you can read Delimited String Parsing in SQL Server 2005 or later ( by BrandonGalderisi (h…
    Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now