I have the following code in Stata 17 that aims to run a command when the suffixes match. In other words, use days_a with freq_a, days_b with freq_b, and so on. However, it still gives me all combinations from valist 1 and varlist 2. Do you know what is wrong with my code? Thank you!
foreach var1 of varlist days_a days_b days_c days_d days_e days_f days_g days_h days_i days_j {
local var1suffix substr("`var1'", strpos("`var1'", "_")+1, length("`var1'"))
foreach var2 of varlist freq_a freq_b freq_c freq_d freq_e freq_f freq_g freq_h freq_i freq_j {
local var2suffix substr("`var2'", strpos("`var2'", "_")+1, length("`var2'"))
if "`var1suffix'" == "`var2suffix'" & "`var1suffix'" != "" {
total(`var1'), over(`var2')
}
}
}
Related Posts with Creating a loop to run a command when the suffixes match
Use Outreg2 with Heckprob commandHi, does anyone know how to get the results (main and selection) obtained from a " heckprob" command…
identify sequence!Dear All, Suppose that I have the data Code: clear input long stkcd int year float dummyvar 10 200…
How to create and interpret the interaction term in the following: lnY=*β0 +*β1 lnGDP +*β2 lnFX +*β3 (lnGDP x lnFX) +*ξHello, I regress a bank's one balance sheet item(Y) on GDP, FX (foreign exchange rate), and the int…
Importing .mbd file into Stata in Mac (Configuring odbc datasources)Hi, I am using Stata 15 and Mac OS Mojave 10.14.2. I have multiple databases in .mbd format, and I w…
Exporting regression results to a Word documentHi all, I'll be very happy if you can help me. I'm trying to export the results of multiple regress…
Subscribe to:
Post Comments (Atom)
0 Response to Creating a loop to run a command when the suffixes match
Post a Comment