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
Replace the first date of the first quarter with the last date of the first quarter for all ids and years.Dear All, I found this question here (https://bbs.pinggu.org/thread-10256921-1-1.html). The data set…
What does ", noconstant" do to standard error?I tried to suppress the constant in a regression, the coefficient is correct but the standard error …
how to calculate adult equivalenthi I'm new in stata, and I need some help to resolve my problem I want to calculate expenditure per …
export correlationmatrix from stata to excelHello everybody, I created a correlationmatrix with the following code: pwcorr roa roe size indust…
graph twoway: two x-axis, lines and line labellingHi folks - apologies a bit of a beginner with the plotting in Stata, but was wondering if anyone kne…
Subscribe to:
Post Comments (Atom)
0 Response to Creating a loop to run a command when the suffixes match
Post a Comment