I'm using SAS EG 5.1 on Windows 7.
I have the following sample input.
I wish to order this input in such a way that whenever different observations match on ID and on Time, the final state of a given observation matches the initial state of the next observation.
The output should look like this:
I'm at a loss on how to do this. Any help?
Here's the code that generates the input table.
Data Test;
Infile datalines delimiter=',';
Input ID Initial_Stafe $ Final_State $ Time;
Datalines;
123,AA,BB,201701020923
123,BB,CC,201701020930
156,AA,AA,201701020910
163,AC,BC,201701031010
163,DD,CC,201701031010
163,BC,DD,201701031010
163,CC,BB,201701031010
170,BB,.,201701040930
;
Assuming that state has logical (and unbreakable) path.
Also assuming that state is global, the order is the same independent of id, or...?
If so, create a lookup table with a your state and a numerical order by variable, merge/join to get this order by variable, and then resort.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.