BookmarkSubscribeRSS Feed
molla
Fluorite | Level 6

How to find the unscheduled visits?

001     01jan2012      10

001     08jan2012       20

001     20jan2012       30

001     27jan2012       40

001     02jan2012       99

001     03jan2012       99

002     02jan2012      10

002     05jan2012      20

002     03jan2012      99

3 REPLIES 3
Reeza
Super User

What's the definition of an unscheduled visit? 

Please post the data as a data step, see examples from your previous questions as well as what the results should look like. Anything you've tried so far would also be helpful. 

 

PS. It seems like you post a question, then try to work on it or continue working on it.  I would highly suggest trying to phrase your questions according to the 'How to Ask a Good Question' guidelines. 80% of the time I find the answer myself before I finish that process. 

 

https://stackoverflow.com/help/how-to-ask

https://stackoverflow.com/help/mcve

Reeza
Super User

Thanks for the slightly more descriptive subject line 😉

art297
Opal | Level 21

I am guessing that you want to identify the dates where doses were missed. If that is so, then one possibility would be:

 

data test;
  informat date date9.;
  format date date9.;
  input id $ date dose;
  cards;
001     01jan2012      10
001     08jan2012       20
001     20jan2012       30
001     27jan2012       40
001     02jan2012       99
001     03jan2012       99
002     02jan2012      10
002     05jan2012      20
002     03jan2012      99
;

data want (drop=date last_date dose rename=(missed_date=date));
  set test;
  format missed_date date9.;
  by id;
  last_date=ifn(first.id,date,lag(date));
  if date-last_date gt 1 then do;
    do missed_date=last_date+1 to date-1;
      output;
    end;
  end;
run;

Art, CEO, AnalystFinder.com

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1249 views
  • 0 likes
  • 3 in conversation