Hi All,
I am trying to create a local that will ultimately serve as the "if" qualifier for a tabulation, etc... The issue I am hitting up against is how to get the local to put quotes around the string values I am specifying in the local? Here is some example code to show what I mean:
The local "ifs" now looks like this:
I obviously need A, C and D to have quotes around them for this local "ifs" to work, but the local naturally puts quotes around the whole string within the local, so if I specify instead:
I get this:
I've also tried double quotes, e.g. `"`a'"', but that doesn't do the trick either... I am guessing that I am missing something very basic here, but alas, I cannot figure it out!
Any help is appreciated!
Ariel
I am trying to create a local that will ultimately serve as the "if" qualifier for a tabulation, etc... The issue I am hitting up against is how to get the local to put quotes around the string values I am specifying in the local? Here is some example code to show what I mean:
Code:
clear set obs 1000 local past A C D local pastcnt: list sizeof past // empty local if local ifs if forvalues i = 1 / `pastcnt' { gen alpha`i' = char(runiformint(65,68)) local a : word `i' of `past' if `i' < `pastcnt' { local and & } else local and // loop to fill up the local ifs local ifs `ifs' alpha`i' == `a' `and' } di "`ifs'"
Code:
if alpha1 == A & alpha2 == C & alpha3 == D
Code:
local ifs `ifs' alpha`i' == "`a'" `and'
Code:
if alpha1 == A" & alpha2 == "C" & alpha3 == "D"" invalid name
Any help is appreciated!
Ariel
Comment