Hello Everyone,
I appreciate some help with the following code. I've exhausted all quotation marks/ backtick combinations to no luck.
This is a simple program that has aa bb and cc, all strings as inputs.
Then I want the permutations of them : aa bb, aa cc then bb cc.
So I read aa first as var1, and put it in var1s to later know aa was already used. Then var2 will bb so I get aa bb and then cc so I get aa cc.
Now I go to the second var1 which will be bb. I put this in var1s for future. Then I read var2 which is aa bb and cc.
Now I want the program to use inlist and know that aa is already used and so don't try bb aa and so on.
This program just understands the new addition not what I stored in var1s.
capture drop local var1s
//local testvariables "aa" "bb" "cc"
local testvariables `""aa", "bb", "cc""'
local var1s=.
foreach var1 of local testvariables{
local var1s `" "`var1s'", "`var1'" "'
foreach var1 of local var1s{
di" members of var1s"
di "`var1'"
}
foreach var2 of local testvariables {
di"var2"
di"`var2'"
scalar result=inlist("`var2'", `var1s')
display result
} //loopvar2
} //loopvar1
I greatly appreciate your input.
I appreciate some help with the following code. I've exhausted all quotation marks/ backtick combinations to no luck.
This is a simple program that has aa bb and cc, all strings as inputs.
Then I want the permutations of them : aa bb, aa cc then bb cc.
So I read aa first as var1, and put it in var1s to later know aa was already used. Then var2 will bb so I get aa bb and then cc so I get aa cc.
Now I go to the second var1 which will be bb. I put this in var1s for future. Then I read var2 which is aa bb and cc.
Now I want the program to use inlist and know that aa is already used and so don't try bb aa and so on.
This program just understands the new addition not what I stored in var1s.
capture drop local var1s
//local testvariables "aa" "bb" "cc"
local testvariables `""aa", "bb", "cc""'
local var1s=.
foreach var1 of local testvariables{
local var1s `" "`var1s'", "`var1'" "'
foreach var1 of local var1s{
di" members of var1s"
di "`var1'"
}
foreach var2 of local testvariables {
di"var2"
di"`var2'"
scalar result=inlist("`var2'", `var1s')
display result
} //loopvar2
} //loopvar1
I greatly appreciate your input.
Comment