I ended up using the countw() function as my workhorse. Here is my final solution: data temp;
set var_list;
if index(lowcase(name), "__c") > 0 then ix="true";
count = countw(name, "_");
run;
data temp2;
set temp;
newstring=tranwrd(name, "__C", '');
run;
data temp4;
set temp2;
count = countw(newstring, "_");
len = length(name);
IF index(newstring, "OBS") then obs="true";
if index(newstring, "PER") then per="true";
if (length(newstring) - index(newstring, "OBS")) > 2 then breakOBS="true";
if (length(newstring) - index(newstring, "PER")) > 2 then breakPER="true";
IF obs = "true" and breakobs="true" then make_list1 = "true";
if per = "true" and breakper="true" then make_list2 = "true";
if count > 4 then make_list3 = "true";
if make_list1 = "true" or make_list2 = "true" or make_list3 = "true" then made_list = "true";
run;
data list(keep=name);
set temp4;
if made_list = "true";
run;
... View more