Hello @PGStats I added the code provided above and I got the error below: Thanks! 2128 data str; 2129 /* The daily sequence of events will be represented as a string with one 2130 letter per day, as follows 2131 2132 i: Initial Interview, 2133 r: Re-Interview, 2134 s: Services Delivered 2135 x: Nothing 2136 */ 2137 2138 /*Prepare a pattern to match all the following conditions: 2139 2140 •The client must have an Initial Interview. 2141 •The client must have three subsequent Re-Interviews. 2142 •The client must have at least one service delivered between the Assessments (within 6 2142! months from the Initial Interview) 2143 •The Re-Interviews should be 5-7 months from the previous one 2144 */ 2145 2146 if not prxId1 then 2147 prxId1 + prxParse("/i((x*)s[sx]*)r(x*[sx]*)r(x*[sx]*)r/"); 2148 2149 /* Transform the sequence of events for a given clientid into a string with 2150 one letter per day */ 2151 length str $30000; /* Max sequence length: more than 5 years */ 2152 do until(last.clientid); 2153 pdate = date; 2154 set have; by clientid; ERROR: Variable str has been defined as both character and numeric. 2155 if not first.clientid then do; 2156 days = intck("day", pdate, date); 2157 if days >= 2 then str = cats(str, repeat("x", days-2)); 2158 end; 2159 str = cats(str, first(form_final)); 2160 end; 2161 2162 length c $1;*/ 2163 c = lowcase(first(left(form_final))); 2164 if c in ("i", "r", "s") then str = cats(str, c); 2165 else str = cats(str, "x"); 2166 2167 /* Check if the string matches the pattern */ 2168 start = 1; 2169 stop = length(str); 2170 call prxNext(prxId1, start, stop, str, pos, len); 2171 2172 /* Check the inter-event durations (nb of chars = nb of days) */ 2173 if pos > 0 then ok = 2174 /* first service after Initial Interview within 6 months */ 2175 length(prxPosn(prxId1,2,str)) <= 182 and 2176 /* inter-Re-Interview times between 5 and 7 months */ 2177 152 <= length(prxPosn(prxId1,1,str)) <= 212 and 2178 152 <= length(prxPosn(prxId1,3,str)) <= 212 and 2179 152 <= length(prxPosn(prxId1,4,str)) <= 212; 2180 2181 /* Recover the events corresponding to the matched substring */ 2182 i = 0; 2183 do until(last.clientid); 2184 pdate = date; 2185 set have; by clientid; ERROR: Variable str has been defined as both character and numeric. 2186 if not first.clientid then do; 2187 days = intck("day", pdate, date); 2188 if days >= 2 then i = i + days - 1; 2189 end; 2190 i = i + 1; 2191 if ok and i >= pos and i < pos + len then output; 2192 end; 2193 2194 keep clientid category date; 2195 run; NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.STR may be incomplete. When this step was stopped there were 0 observations and 3 variables. WARNING: Data set WORK.STR was not replaced because this step was stopped. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.03 seconds
... View more