Hi:
Even though you can write your XML as one long quoted string, as you discovered, double quotes inside double quotes lead to other issues in the SAS code. So, there's nothing wrong with writing part of the string in SINGLE quotes and then part of the string in DOUBLE quotes, so the macro variable resolves correctly and you do not get quoting issues in the compiler.
This program
[pre]
%let test=abc;
data _null_;
file 'c:\temp\fakexml.xml';
put @1 ''
"&test.";
run;
[/pre]
produces this outout in the c:\temp\fakexml.xml file:
[pre]
<test><testdo yyy="abc"><test1 xxx="x">abc</test1></testdo></test>
[/pre]
You could also use syntax in your DATA step program like this (I know, this isn't valid XML, but I was more interested in showing a couple of different quoting possibilities with the macro variable):
[pre]
. . . more code . . .
put '** Another example';
put @1 '<wombat>'
"&test"
'<test1 koala="' "&test&test" '">wombat</test1>';
[/pre]
to produce this output in the file created by the PUT statements:
[pre]
** Another example
<wombat>abc<test1 koala="abcabc">wombat</test1>
[/pre]
Log from the complete program is shown below.
cynthia
[pre]
88 %let test=abc;
89 data _null_;
90 file 'c:\temp\fakexml.xml';
91 put @1 '<test><testdo yyy="abc"><test1 xxx="x">'
92 "&test.</test1></testdo></test>";
93
94 put '** Another example';
95 put @1 '<wombat>'
96 "&test"
97 '<test1 koala="' "&test&test" '">wombat</test1>';
98 run;
NOTE: The file 'c:\temp\fakexml.xml' is:
Filename=c:\temp\fakexml.xml,
RECFM=V,LRECL=256,File Size (bytes)=0,
Last Modified=18Oct2010:10:13:41,
Create Time=18Oct2010:08:52:49
NOTE: 3 records were written to the file 'c:\temp\fakexml.xml'.
The minimum record length was 18.
The maximum record length was 66.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.00 seconds
[/pre]