How to perform the following data operations as follows:

(1) Place the data scattered in multiple rows on one row

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input str2(a b c d)
"a"  ""   ""   ""  
""   "b"  ""   ""  
""   ""   "c"  ""  
""   ""   ""   "d" 
"fd" ""   ""   ""  
""   "fe" ""   ""  
""   ""   "fe" ""  
""   ""   ""   "ef"
"de" ""   ""   ""  
""   "ss" ""   ""  
""   ""   ""   ""  
""   ""   ""   "fw"
"cc" ""   ""   ""  
""   "fd" ""   ""  
""   ""   "ef" ""  
""   ""   ""   "ge"
end
My goal is to transform the data into the following data

Array


(2) How to store the serial number of a specific value in a variable A, or how to store the value of another variable B corresponding to a specific value in a variable A for subsequent operations

The data are the same as aboveL

Array

We want to store the serial number of the variable A when it is not empty, that is, the value of the corresponding variable obs ( the value of the red in the figure ), in the temporary element for subsequent data operations.

Looking forward to your reply, looking forward to your help, Thank you very much,