Hi all,
I’ve come across some (to me) odd behavior regarding how sprint handles string substitution. I have several regressions that I’m running in a loop, and I want to save the associated model table in new file each time through. This seems
like it should work (on Windows 7, current snapshot):
<hansl>
list xlist = (names of relevant variables)
vnames = varnames(xlist)
loop foreach i xlist
# run regressions, save to model table, etc.
foo = vnames[i] # string with dependent variable name
foo ~= “.tex”
sprintf fname “C:\Users\psummers\Documents\my directory\%s”, foo
</hansl>
However the sprintf command generates a syntax error (“sprintf: unprocessed argument(s): ‘foo’Syntax error”). If I replace the last backslash with something else (eg a comma), it works fine. At the moment that’s my work-around (combined
with using strsub to switch the comma back to “\”, of course).
According to the user’s guide, the “\” character isn’t “special” within sprintf, but it seems to be causing some problems here.
TIA,
PS