I am having a problem with generating a string with quotes in it with a -forvalues- loop. I am using Stata/SE 17.0 for Windows.
I want to create the labStrGoal string for a label in a graph via the -forvalues- loop for generalization purposes but get the error message:
3" " invalid name
r(198);
. local LabStrGoal = `"1 "1/3" 2 "2/3" 3 "3/3" 4 "4/3""'
. local LabStr = ""
. forvalues n = 1 (1) 4 {
2. local add = "`n'" + " " + `" "`n'/3" "' + " "
3. local LabStr = "`LabStr'" + "`add'"
4. display "`LabStr'"
5. }
3" " invalid name
r(198);
What should I change in the code?
Thanks in advance for your consideration.
Marnix
I want to create the labStrGoal string for a label in a graph via the -forvalues- loop for generalization purposes but get the error message:
3" " invalid name
r(198);
. local LabStrGoal = `"1 "1/3" 2 "2/3" 3 "3/3" 4 "4/3""'
. local LabStr = ""
. forvalues n = 1 (1) 4 {
2. local add = "`n'" + " " + `" "`n'/3" "' + " "
3. local LabStr = "`LabStr'" + "`add'"
4. display "`LabStr'"
5. }
3" " invalid name
r(198);
What should I change in the code?
Thanks in advance for your consideration.
Marnix
Comment