07-21-2014 03:02 PM
I have this data set that I would like to put a counter based on the different location of the patient goes to during a visit.
Here is an example of the dataset and ID is the counter that I am trying to place but the counter is not doing what I wanted at the moment
|Visit||Check In DateTime||Location||SubLocation||ID|
|123||7/2/2014 14:00||Emergency||Room 2||1|
|123||7/2/2014 15:00||Emergency||Room 10||1|
|123||7/2/2014 18:30||Surgery||Room 4||2|
|123||7/2/2014 18:30||Bed||Room 123||3|
Basically this is one visit, at different locations that's when I want the ID to increment by 1.
The purpose of this is at certain locations I take the first location the patient went to during the visit and certain locations I would use the second location patient went to for the visit. Additionally it allows me order the patient's location history.
07-21-2014 03:10 PM
If you can assume your data is sorted by patient/date/location you can use the following. The key is the notsorted option on the by statement.
by visit location NOTSORTED;
if first.visit then id=0;
if first.location then id+1;