Hi,

I want to assign a binary code to each column, 1 if it contains information from the first row and 0 otherwise.

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input str33 WHODISCLOSURE2 str31 WHODISCLOSURE3 str26 WHODISCLOSURE4 str24 WHODISCLOSURE5
"Securities regulator - Encourages" "Securities regulator - Requires" "Corporate law - Encourages" "Corporate law - Requires"
""                                  "Requires"                        ""                           ""                        
""                                  ""                                ""                           ""                        
"Encourages"                        ""                                ""                           ""                        
""                                  "Requires"                        ""                           ""                        
"Encourages"                        ""                                ""                           ""                        
"Encourages"                        "Requires"                        ""                           ""                        
""                                  "Requires"                        ""                           "Requires"                
"Encourages"                        ""                                ""                           "Requires"                
""                                  "Requires"                        ""                           ""                        
""                                  ""                                ""                           ""                        
""                                  "Requires"                        "Encourages"                 ""                        
"Encourages"                        ""                                ""                           "Requires"                
"Encourages"                        ""                                ""                           ""                        
""                                  "Requires"                        ""                           ""                        
""                                  ""                                ""                           ""                        
"Encourages"                        ""                                ""                           "Requires"                
""                                  "Requires"                        "Encourages"                 ""                        
"Encourages"                        ""                                ""                           ""                        
""                                  "Requires"                        ""                           ""                        
""                                  ""                                ""                           ""                        
"Encourages"                        ""                                ""                           ""                        
""                                  "Requires"                        "Encourages"                 "Requires"                
""                                  ""                                ""                           ""                        
"Encourages"                        "Requires"                        ""                           ""                        
""                                  ""                                ""                           ""                        
""                                  "Requires"                        ""                           ""                        
""                                  ""                                ""                           ""                        
""                                  "Requires"                        ""                           "Requires"                
""                                  ""                                "Encourages"                 ""                        
""                                  "Requires"                        ""                           "Requires"                
"Encourages"                        "Requires"                        ""                           "Requires"                
""                                  "Requires"                        "Encourages"                 ""                        
""                                  ""                                ""                           ""                        
""                                  "Requires"                        ""                           ""                        
"Encourages"                        ""                                ""                           "Requires"                
""                                  "Requires"                        ""                           ""                        
"Encourages"                        "Requires"                        ""                           ""                        
""                                  "Requires"                        "Encourages"                 ""                        
""                                  ""                                ""                           ""                        
"Encourages"                        "Requires"                        ""                           ""                        
""                                  "Requires"                        ""                           "Requires"                
""                                  ""                                ""                           ""                        
""                                  ""                                ""                           ""                        
"Encourages"                        ""                                ""                           ""                        
""                                  "Requires"                        ""                           ""                        
"Encourages"                        ""                                "Encourages"                 ""                        
"Encourages"                        ""                                "Encourages"                 ""                        
""                                  ""                                ""                           ""                        
""                                  ""                                ""                           ""                        
""                                  ""                                ""                           ""                        
""                                  ""                                ""                           ""                        
"Encourages"                        ""                                "Encourages"                 ""                        
end
I have tried:

Code:
local N = _N
forvalues i = 2/`N'{
foreach j of varlist WHODISCLOSURE* {
local m1 = `j'[1] 
if `j'[`i'] == "`m1'" {
replace `j' = "1" in `i' if `j' != ""
}
replace `j' = "0" in `i' if `j' == ""
}
}
However, it doesn't work because the text doesn't exactly match what's in the first line. Does anyone know how to retrieve some information to use from an inexact match?
Many thanks in advance!