BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Anonymous10
Calcite | Level 5

I have a table of meetings that contains meeting information.

However some meetings are rescheduled for a new time or date. These meetings appear twice or more in the dataset.

 

I want to keep only the information for the last meeting, however I would like to store the information on how many times the meeting have been rescheduled.

How can I achieve this in SAS?

 

The key data that I have is:

MeetingID                          CustID                 Meetingdate    MeetingTime

Timestamp at booking         ID                            Date              Time

 

 

What I want:

CustID                      Meetingdate          Meetingtime        Number of reschedules

ID                                   Date                       Time                     #

 

I realize that if a meeting is rescheduled it can still appear twice, however this is a only a minor issue.

If there is a smart solution to allow to count rescheduled meetings say within +-15 days this would be excellent, but not a necessary requirement. 

 

CustID                      Meetingdate          Meetingtime        Number of reschedules on this date        Meetings within +-15 days

ID                                   Date                       Time                          #                                                                     #

 

As I am new to SAS i'm not able to achieve this by code, hopefully someone has a smart solution.

I'm using SAS EG 8.2.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

First, sort by meeting ID and meeting date/time

Then do

data want;
set have;
by meeting_id;
if first.meeting_id
then reschedules = 0;
else reschedules + 1; /* use of sum statement causes automatic retain */
if last.meeting_id; /* only keep last observation of a group */
run;

For tested code, supply example data in usable form, as a data step with datalines.

View solution in original post

1 REPLY 1
Kurt_Bremser
Super User

First, sort by meeting ID and meeting date/time

Then do

data want;
set have;
by meeting_id;
if first.meeting_id
then reschedules = 0;
else reschedules + 1; /* use of sum statement causes automatic retain */
if last.meeting_id; /* only keep last observation of a group */
run;

For tested code, supply example data in usable form, as a data step with datalines.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 671 views
  • 0 likes
  • 2 in conversation