Hi all,

I am writing since I have a potentially simple task which however I am not able to figure out.
I used
Code:
fillin
to complete my dataset. The dataset basically consists in trade flows exporter and importer and looks like that:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str4 hs4codeprod str3(exporter_iso_3digit importer_iso_3digit) float tradevalue
"0101" "ABW" "MNG"        14
"0101" "AFG" ""            .
"0101" "AGO" ""            .
"0101" "AIA" ""            .
"0101" "ALB" ""            .
"0101" "AND" "ESP"     1.498
"0101" "AND" "FRA"  3.743777
"0101" "AND" "ESP" 115.29078
"0101" "ANT" "USA"    12.333
"0101" "ARE" "IRL"   1944.82
"0101" "ARE" "GBR"   568.524
"0101" "ARE" "SGP"    28.325
"0101" "ARE" "BHR"    81.537
"0101" "ARE" "OMN"    41.456
"0101" "ARE" "DEU"        61
"0101" "ARE" "ESP"     14.28
"0101" "ARE" "GBR" 147193.83
"0101" "ARE" "BHR"     6.715
"0101" "ARE" "FRA"   108.223
"0101" "ARE" "ZAF"    15.159
"0101" "ARE" "FRA"  1705.441
"0101" "ARE" "USA"         6
"0101" "ARE" "DEU"         6
"0101" "ARE" "NLD"     4.977
"0101" "ARE" "SAU"      69.6
"0101" "ARG" "GBR"  969.3669
"0101" "ARG" "USA"  2141.565
"0101" "ARG" "BRB"      32.4
"0101" "ARG" "DEU" 353.28915
"0101" "ARG" "COL"  77.70284
"0101" "ARG" "NLD"   6.14416
"0101" "ARG" "ARE"     418.1
"0101" "ARG" "MEX" 14.122561
"0101" "ARG" "ZAF"   712.801
"0101" "ARG" "FRA" 17.431187
"0101" "ARG" "ITA"   917.708
"0101" "ARG" "USA"  520.8932
"0101" "ARG" "NOR" 18.761257
"0101" "ARG" "PAN"  38.55169
"0101" "ARG" "SGP"  93.49046
"0101" "ARG" "CHL"   95.4077
"0101" "ARG" "CHE"       4.7
"0101" "ARG" "PAN"         3
"0101" "ARG" "GBR"  40.12939
"0101" "ARG" "CRI"  99.63808
"0101" "ARG" "PER"       1.5
"0101" "ARG" "DEU"  4.360299
"0101" "ARG" "ESP"  55.80306
"0101" "ARG" "SLV"    31.543
"0101" "ARG" "ECU"     5.018
"0101" "ARG" "PRY" 25.379276
"0101" "ARG" "COL"   69.9673
"0101" "ARG" "IND"       7.8
"0101" "ARG" "THA" 23.625923
"0101" "ARG" "BEL"         6
"0101" "ARG" "BOL" 15.580288
"0101" "ARG" "MYS"      62.4
"0101" "ARG" "SLV"      15.6
"0101" "ARG" "HKG"   320.062
"0101" "ARG" "SAU"       243
"0101" "ARG" "ESP"  108.9865
"0101" "ARG" "SAU"         3
"0101" "ARG" "BRA"  40.80972
"0101" "ARG" "URY"  43.23571
"0101" "ARG" "BRA"  45.71266
"0101" "ARG" "VEN"      64.8
"0101" "ARG" "MAR"      31.2
"0101" "ARG" "MAC"  23.60933
"0101" "ARG" "ARE"         8
"0101" "ARG" "CHL"  24.99566
"0101" "ARG" "BOL"      5.35
"0101" "ARG" "NGA"      73.2
"0101" "ARG" "SWE"        33
"0101" "ARG" "URY"  115.3789
"0101" "ARG" "NLD"  314.9152
"0101" "ARG" "FRA"  825.8044
"0101" "ARG" "PRY"        25
"0101" "ARG" "PER"  31.85023
"0101" "ARG" "CRI"    10.042
"0101" "ARG" "ITA" 30.429615
"0101" "ARG" "ECU"  68.43581
"0101" "ARG" "CAN"  176.9125
"0101" "ARG" "MEX"    20.396
"0101" "ARG" "SGP"    41.319
"0101" "ARM" ""            .
"0101" "ASM" ""            .
"0101" "ATA" ""            .
"0101" "ATF" ""            .
"0101" "AUS" "PHL"      14.7
"0101" "AUS" "BRN"     4.033
"0101" "AUS" "THA"  345.3494
"0101" "AUS" "VNM" 228.47566
"0101" "AUS" "ZAF"  1024.895
"0101" "AUS" "THA"    175.41
"0101" "AUS" "ARE"  1716.551
"0101" "AUS" "NCL" 126.42155
"0101" "AUS" "NZL" 10164.123
"0101" "AUS" "HKG" 18563.896
"0101" "AUS" "NCL"  7.529643
"0101" "AUS" "IDN"    23.925
end

The fillin has been made as follows:
Code:
fillin hs4codeprod exporter_iso_3digit
hs4codeprod represents the product code.

As you can see some tradevalue are missing. I would like to replace them however using the following criterion: if product p is missing for country c but country c appears a importer (i.e. in the column importer_iso_3digit) of the same product with one (or more) other country(ies), then the missing tradevalue should be replaced by 0.
Is that possible? I was guessing something with Cond() but I cannot figure out yet a smart way.

Thank you