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.
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.
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.
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!
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.