Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9199359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:31:07+00:00 2026-06-17T22:31:07+00:00

I have an issue i am stuck on trying to sort out…i basically have

  • 0

I have an issue i am stuck on trying to sort out…i basically have a table that looks a little something like this..

ID    user    operation     date
1     Jon     In         01/01/2013
1     Paul    Out        02/01/2013
1     Paul    In         03/01/2013
2     Jon     Deleted    04/01/2013
2     Paul    In         05/01/2013
2     Jon     Out        06/01/2013
1     Jon     out        07/01/2013
1     Jon     Deleted    08/01/2013
2     Jon     out        09/01/2013 
1     Jon     in         11/01/2013

So basically i need to find where for the same ID both Jon and Paul are “In”. So in the example about Jon and Paul are both in for ID 1, and for ID 2 i will only find Paul. So the last known date for that row has to be included as the early in, out or deleted is it be ignored as it was later changed. So in short i need to find ID values where an IN existes and that has not been later set to “out” or Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:31:08+00:00Added an answer on June 17, 2026 at 10:31 pm

    If you sort the data correctly then using first. in a data step should work (unless you have an id and user with more than 1 entry on the same day, you’d need to determine which one to take if that were the case).

    data have;
    input ID user $ operation $ date :mmddyy10.;
    format date mmddyy10.;
    cards;
    1     Jon     In         01/01/2013
    1     Paul    Out        02/01/2013
    1     Paul    In         03/01/2013
    2     Jon     Deleted    04/01/2013
    2     Paul    In         05/01/2013
    2     Jon     Out        06/01/2013
    1     Jon     out        07/01/2013
    1     Jon     Deleted    08/01/2013
    2     Jon     out        09/01/2013 
    1     Jon     in         11/01/2013
    ;
    run;
    
    proc sort data=have;
    by id user descending date;
    run;
    
    data want;
    set have;
    by id user;
    if first.user and lowcase(operation)='in' then output;
    run;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am stuck with a peculiar issue here. I have a script that basically
Stuck trying to figure out the best algorithm here. I have this simple function
so i have been stuck with this issue for 3 weeks now and i
So I have this issue with setting a margin that dynamical decreases and increases
Have been stuck on this (beginner) issue for a while so am now asking
Have been stuck with this issue for a few days now, and really need,
I am trying to learn Backbone.js and have stuck at an issue. model.save is
I`m new to sql and have been stuck on the following issue for almost
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
Okay, I think I might be over-complicating this issue but I truly am stuck.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.