I am currently cleaning survey data that contains 1000+ variables many of which need to be renamed because they are inappropriately numbered.
For example some of the variables in the dataset are (changed names for anonymity)

pt1surveyoption_1_2_1
pt1surveyoption_1_2_2
pt1surveyoption_1_2_3
pt1surveyoption_1_2_4
pt1surveyoption_2_2_1
pt1surveyoption_2_2_2
pt1surveyoption_2_2_3
pt1surveyoption_2_2_4

pt2surveyoption_1_2_1
pt2surveyoption_1_2_2
pt2surveyoption_1_2_3
pt2surveyoption_1_2_4
pt2surveyoption_2_2_1
pt2surveyoption_2_2_2
pt2surveyoption_2_2_3
pt2surveyoption_2_2_4


For reshaping the data accurately Where _#_#_# means _optionnumber_individualnumber_groupnumber

pt1surveyoption_1_1_2
pt1surveyoption_2_1_2
pt1surveyoption_3_1_2
pt1surveyoption_4_1_2
pt1surveyoption_1_2_2
pt1surveyoption_2_2_2
pt1surveyoption_3_2_2
pt1surveyoption_4_2_2

pt2surveyoption_1_1_2
pt2surveyoption_2_1_2
pt2surveyoption_3_1_2
pt2surveyoption_4_1_2
pt2surveyoption_1_2_2
pt2surveyoption_2_2_2
pt2surveyoption_3_2_2
pt2surveyoption_4_2_2

The goal is to have a loop where I will search through varlist _all and pick out varnames which correspond to the _#_#_# format (because many do not) and then reorder it so that way the last number gets bumped to the front as you can see above. I have tried to has() function but I do not know how to specify that format to make a patternlist and do not know how to use said function to make a list to of variables. Any help or direction to a similar solved problem would be much appreciated thank you.