I would like to keep variables if the third-row value is SHD.
If the third-row value is not SHD, I would like to delete all the variables.

I do not want to use the 'xpose 'command because the data is very long, so it is not workable.
In my dataset, there are more than 2000 variables including more than 100 SHD and more than 30000 observation.
I tried the below code but failed.
I would like to use logic similar to the below.
PLZ let me know good ways.



foreach var of varlist * {
drop `var' if `var'[3] == "SHD"
}

V119 V534 V1461 V1942 V1943 V2165 V2542 V2543 V2791 V3002 V3046
1968 1968 1968 1968 1968 1968 1968 1968 1968 1968 1968
1 2 3 4 5 6 7 8 9 10 11
SEX FMN SHD AGE SEX SHD AGE SEX SHD 1973 MI_Y
1 1
1 49 2 5 50 2 5 81 5179
1 5 24 1 5 25 1 5 17 8000
1 2
1 59 2 5 60 2 5 2285 0
1 3 5 82 1 5
1 4 5 48 1 5 49 1 5 430 0
20 1 1 432 5200