Reputation: 31
I am using the following forvalues loop but it gives me error,
forvalues i=1/22919 {
quietly replace standarisedname="`y`i''" if schoolname=="`x`i''" & missing(standarisedname)
}
type mismatch (r(109)) error
But when I use compound double quotes, like
forvalues i=1/22919 {
quietly replace standarisedname=`"`y`i''"' if schoolname==`"`x`i''"' & missing(standarisedname)
}
too few quotes error is returned
and when I use,
forvalues i=1/22919 {
quietly replace standarisedname=""`y`i''"" if schoolname==""`x`i''"" & missing(standarisedname)
}
forvalues i=1/22919 {
quietly replace standarisedname="`"`y`i''"'" if schoolname=="`"`x`i''"'" & missing(standarisedname)
}
invalid 'public' error(198) is returned.
Thanks for help!
Upvotes: 0
Views: 1879
Reputation: 37208
This isn't a full answer, but it is long and contains too much syntax to be a comment. It's hard to see what the real problem here is, as your example isn't reproducible.
The implication is that you have 2 x 22919 local macros named y1
to y22919
and x1
to x22919
. Correct?
A type mismatch would imply that one or both of the variables you are referring to is not string. Please show us the results of
describe schoolname standardisedname
I can't see unmatched quotes in your second example.
In your last example
""`y`i''""
and similar uses evidently don't help you. Nesting ""
doesn't usually help. Presumably public
is part of the text of one of the local macros you are using.
I suggest you back-up and explain what you are trying to do, as my sense is that there will be an easier way to do it.
Upvotes: 1