Trying to code data so I can count the number of times the phrase "Medicare" appears in the insurance type listed. I used the index only to see that it counts where in the phrase it occurs for example, Secondary Medicare, was counted as 11. Is there any way to eliminate the characters that appear before Medicare so I can create a variable that properly counts the number of patients with any type of Medicare insurance?
 
 
This was the original code I used:
data test;
set insurance;
Medicare = index (Insurancetype,'Medicare');
run;
 
 
data have:
 
Studyid     Insurancetype                                        Medicare
3548           Medicare                                                   1
6789            Managed Medicare                                  9
4567             Auto Generic/Secondary Medicare        25
 
data want:
Studyid     Insurancetype                                        Medicare
3548           Medicare                                                   1
6789            Managed Medicare                                  1
4567             Auto Generic/Secondary Medicare         1