I have a dataset representing a treated unit (GDP), a series of estimated counterfactuals, (cf) and pointwise treatment effects (diff_). Let's inspect what I've got.
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input long gdp double cf int year float(diff_ diff_19) double cf_19 float diff_4 double cf_4 float diff_1 double cf_1 float relative
 2284 2382.1523483077835 1960  -98.15235 -239.61543  2523.615430234012 -128.92287  2412.922868887859  -156.5139 2440.5139206906247 -30
 2388 2446.6506511192324 1961  -58.65065  -189.2806 2577.2805809334377 -178.53693   2566.53692273034   -142.385   2530.38499218418 -29
 2527 2604.8115880199935 1962  -77.81158  -188.0124 2715.0123993333445 -186.70563 2713.7056316563535 -115.07682 2642.0768231463126 -28
 2610  2724.349430948411 1963 -114.34943 -210.40553  2820.405534499806 -233.68675  2843.686754138453 -157.42615 2767.4261537616703 -27
 2806 2889.9580019727537 1964    -83.958 -178.27428 2984.2742718124796  -115.0309  2921.030893136066 -140.29448  2946.294474600189 -26
 3005 3099.1157042307163 1965  -94.11571 -175.01315  3180.013158727885 -36.343998  3041.343998243464 -104.68647  3109.686466545085 -25
 3168  3359.960375695906 1966 -191.96037  -266.1019  3434.101900463562  -82.81771  3250.817708028666 -132.79723 3300.7972267528758 -24
 3241 3520.2771709761573 1967 -279.27716  -344.3777 3585.3776979131167 -250.44392 3491.4439182434617 -239.84328 3480.8432762798575 -23
 3571 3818.1429155125434 1968  -247.1429 -298.81952 3869.8195290516924 -227.67203 3798.6720259284243 -198.46587 3769.4658603651965 -22
 3998  4115.411017936789 1969 -117.41102   -151.486  4149.485996602814 -141.20108   4139.20108234847 -103.13166  4101.131661014288 -21
 4367  4332.029471182796 1970  34.970528  -7.026773  4374.026773141374 -175.03514  4542.035139627704  -47.44807  4414.448068668981 -20
 4686  4657.291964804378 1971  28.708035 -11.247523  4697.247522840271 -105.25514  4791.255143064456  -61.78067  4747.780672611365 -19
 5055  5086.462070494702 1972  -31.46207  -53.92624  5108.926233933297  -23.07299  5078.072991847272  -54.10266  5109.102663884323 -18
 5553  5646.499101450986 1973   -93.4991  -82.10171  5635.101705764349   -54.6655  5607.665499150371 -142.69818  5695.698185910818 -17
 6074  6130.730898105595 1974   -56.7309 -22.579327  6096.579327380564  -227.6143  6301.614301823399  -153.5402  6227.540215496327 -16
 6603  6635.678217863695 1975  -32.67822   9.549131  6593.450868564118  -86.40922  6689.409220964208  -160.1954  6763.195415566906 -15
 7367  7310.191521860769 1976   56.80848  100.64253  7266.357469068064  -60.40121  7427.401213899765  -8.467811 7375.4678110799205 -14
 8090   8024.42535038122 1977  65.574646   84.27509 8005.7249110951425   90.03732   7999.96268731265   49.71434  8040.285657605269 -13
 8928  8926.148259121721 1978   1.851741   57.40613  8870.593869525446   153.5217  8774.478301441524   64.27234  8863.727662437957 -12
10067  9836.536517859578 1979   230.4635   223.5902  9843.409790618043   162.4379  9904.562110128869  216.52855  9850.471452859647 -11
11083 10666.661733228293 1980   416.3383   432.9714  10650.02859426265   51.57676  11031.42324635798   401.3458 10681.654217847243 -10
12115 11806.043361600614 1981   308.9566   341.7199 11773.280100739687   63.06381 12051.936191465373   469.9802 11645.019818629977  -9
12761 12235.306759606703 1982  525.69324   539.0721 12221.927891952286 -23.557064 12784.557063637207  143.00787 12617.992126276697  -8
13519 13117.384658666579 1983   401.6154   378.0477 13140.952282833236  157.58456  13361.41543366107   83.95309 13435.046902355898  -7
14481 14362.574193051578 1984   118.4258   156.2245 14324.775496315307   334.3267  14146.67328931739  294.18005 14186.819958095495  -6
15291 15243.436752898206 1985   47.56325   83.27309 15207.726906842216   347.2524 14943.747610653902   325.0587 14965.941300613735  -5
15998 15972.494991886613 1986   25.50501   82.64354 15915.356458415343   397.9014 15600.098567980867   276.6529 15721.347114126615  -4
16679 16859.815540052205 1987 -180.81554  -36.51328 16715.513278612565   228.1159  16450.88409695461   42.18883 16636.811167643467  -3
17786 18036.168024604918 1988 -250.16803  -42.37479 17828.374794129002  157.76624  17628.23376836272  -155.0739 17941.073893747514  -2
18994 19248.291406558565 1989  -254.2914   7.740776  18986.25922439489  193.78767 18800.212319007103  -92.95484 19086.954839201564  -1
20465 20224.150759576136 1990  240.84924  525.81714 19939.182854950133  514.29364 19950.706386596594   393.9321 20071.067943179816   0
21602 20738.400966532055 1991   863.5991  1154.2319  20447.76805299464   685.5661 20916.433899914013   941.9903 20660.009702585576   1
22154 21580.174302957952 1992   573.8257   853.8572 21300.142823316975   676.8211 21477.178907646707   866.7733 21287.226699563194   2
21878 22271.115165831437 1993  -393.1152   -109.473  21987.47300196588  -40.68504 21918.685034424747   8.941148 21869.058852596623   3
22371 23360.161454596157 1994  -989.1614  -676.4664 23047.466398700126  -405.9901   22776.9901324677  -620.2714    22991.271386514   4
23035  24195.70462781342 1995 -1160.7046  -803.5131 23838.513081502944  -767.8742 23802.874198338817  -963.2782 23998.278215525206   5
23742   25245.9743769779 1996 -1503.9744 -1161.2825 24903.282474010928  -816.0538  24558.05377771829 -1319.3065 25061.306472021763   6
24156 26466.868505360024 1997 -2310.8684  -1861.107  26017.10710408016 -1019.7327  25175.73266554645 -2332.7148  26488.71495195701   7
24931 27612.192320207047 1998 -2681.1924 -2129.7876 27060.787551848938 -1351.1836 26282.183542873412 -2691.8235 27622.823511233928   8
25755 28983.168196963157 1999  -3228.168  -2599.467 28354.466950375485 -1130.8975  26885.89751671589  -2711.866 28466.865748668202   9
26943 30458.162643152937 2000 -3515.1626  -2849.585  29792.58513357836 -1400.6198 28343.619691990345  -3381.886 30324.886080181062  10
27449 31282.417577475535 2001 -3833.4175  -2956.631 30405.631330885048  -1783.003  29232.00306631015   -4500.46  31949.46011041869  11
28348  32233.17794185473 2002  -3885.178  -2846.022 31194.021767452297 -1672.4836 30020.483594424702  -5242.954 33590.953480535565  12
28855   33459.1985655981 2003 -4604.1987  -3463.965 32318.965141239547 -1398.5902  30253.59023557029  -5341.003  34196.00272261752  13
end
format %ty year
label var gdp "Real West Germany" 
label var cf "Sans All" 
label var diff_19 "Effect Sans Spain" 
label var cf_19 "Sans Spain" 
label var diff_4 "Effect Sans Belgium" 
label var cf_4 "Sans Belgium" 
label var diff_1 "Effect Sans USA" 
label var cf_1 "Sans USA" 
label var relative "Relative Time to German Reunification" 

cls

// Our Fit


mata A=J(0,1,.)
tempname e123

foreach x of var cf* {
    
local cf_lab: variable lab `x'

loc outlab "`cf_lab'" // Grabs the label of our outcome variable


tempvar Yco Ytr

matrix rmse_`x'=J(1, 2, .)

mkmat gdp if rel < 0, mat(`Ytr')

mkmat `x' if rel < 0, mat(`Yco')

mat loss = (`Ytr' - `Yco')' * ( `Ytr' - `Yco')
 
mat loss = loss / rowsof(`Ytr')
 
mata: roottaker("loss")
mat rowname loss = "`outlab'"
mat colname loss = "RMSPE"
matrix `e123'=loss

mata: A=A\st_matrix("`e123'")

}
mata: st_matrix("B",A)

mata C="RMSE"
mata C=C,J(1,1," ")
mata st_matrix("B",A)
mata st_matrixcolstripe("B",C)
mat l B


// Our ATTS


cls
mata T=J(0,1,.)
tempname e123
foreach x of var diff_* {
tempvar difftr

local cf_lab: variable lab `x'

loc outlab "`cf_lab'" // Grabs the label of our outcome variable


mkmat `x' if rel >= 0, mat(`difftr')

mat U = J(rowsof(`difftr'),1,1)

mat sum = U'*`difftr'

/* create vector of column (variable) means */

mat meanvec = sum/rowsof(`difftr')

mat rowname meanvec = "`outlab'"
mat colname meanvec = "ATT"
matrix `e123'=meanvec

mata: T=T\st_matrix("`e123'")

}
mata: st_matrix("B",T)

mata C="RMSE"
mata C=C,J(1,1," ")
mata st_matrix("B",T)
mata st_matrixcolstripe("B",C)
mat l B
I calculate the Root Mean Squared Errors and their ATTs. But, I need each row to reflect the country/unit that was left out. How might I do this? Could I, perhaps extract the string from the variable label? Every string after "Sans", so we'd have "All, Spain..." and so on as the row names? Oh, and as usual, I'm open to any Mata implementation that accomplishes this , as well as any simplification one might offer. Thanks so much!!