Date: Tue, 4 Mar 2008 14:44:51 -0500
Reply-To: Mike Rhoads <RHOADSM1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mike Rhoads <RHOADSM1@WESTAT.COM>
Subject: Re: Question abount counting strings
Content-Type: text/plain; charset="us-ascii"
So, a "state" is equivalent to a single letter, and a "transition" is
the combination of 2 adjacent states/letters, right?
If my understanding is correct, I wouldn't bother with regular
expressions. I would just use a DATA step with a DO-loop to create a
restructured data set with one record for each patient and transition.
You could then use PROC FREQ or some other reporting procedure to count
DATA Transitions (KEEP = patient_id transition);
LENGTH patient_id $ 6 states $ 12 transition $ 2;
INPUT patient_id states;
DO I = 1 TO LENGTH(states) - 1;
transition = SUBSTR(states,I,2);
Note that this does not create any records for patients like 124886, who
have only one state and therefore no transitions. You could modify the
code to create a record for these patients if necessary.
From: firstname.lastname@example.org [mailto:email@example.com]
On Behalf Of Guylhem Aznar
Sent: Tuesday, March 04, 2008 1:19 PM
Subject: Question abount counting strings
I have a problem : after various data steps, I have a record of the
list of states a patient has been in, ex:
I would like to count the transition between the states - in perl I
would simply count the possible strings (NH, NP, PH, HP, HD, PD...)
How could I easily do that with that ?
There's a trick : a patient can return to previous states, or
alternate betweem states like NHPHPD (n=new, d=death) : here there
should be 2 HP and 1 PH.
I have learn about the prx commands, but I have a hard time
translating from my regexp logic to their logic.
Any help would be welcome.