<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Need to remove double quotes but leave the original ones already in data? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Need-to-remove-double-quotes-but-leave-the-original-ones-already/m-p/18378#M3596</link>
    <description>Thanks for the reply. &lt;BR /&gt;
&lt;BR /&gt;
You say you want to insert some XML into a "little table" -- is that little table in CSV format??? &lt;BR /&gt;
Lee&amp;gt;The source table contained one variable and one record. The xml string is hardcoded apart from one bit,which is a variable.&lt;BR /&gt;
&lt;BR /&gt;
How did you create the table? &lt;BR /&gt;
Lee&amp;gt;I create the table in the code attached. Just one column, one record.&lt;BR /&gt;
&lt;BR /&gt;
Your programmed worked &lt;BR /&gt;
6912  data _null_;&lt;BR /&gt;
6913  file "C:\temp\test.xml";&lt;BR /&gt;
6914  put @1 '&lt;TEST&gt;&lt;TESTDO yyy="abc"&gt;&lt;TEST1 xxx="x"&gt;xyz&lt;/TEST1&gt;&lt;/TESTDO&gt;&lt;/TEST&gt;';&lt;BR /&gt;
6915  run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: The file "C:\temp\test.xml" is:&lt;BR /&gt;
      File Name=C:\temp\test.xml,&lt;BR /&gt;
      RECFM=V,LRECL=256&lt;BR /&gt;
&lt;BR /&gt;
NOTE: 1 record was written to the file "C:\temp\test.xml".&lt;BR /&gt;
&lt;BR /&gt;
But when I change it to support variable input and change the outside quotes to double quotes it has a problem with this solution.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
6916  %let test=abc;&lt;BR /&gt;
6917  data _null_;&lt;BR /&gt;
6918  file "C:\temp\test.xml";&lt;BR /&gt;
6919  put @1 "&lt;TEST&gt;&lt;TESTDO yyy="abc"&gt;&lt;TEST1 xxx="x"&gt;&amp;amp;test.&lt;/TEST1&gt;&lt;/TESTDO&gt;&lt;/TEST&gt;";&lt;BR /&gt;
             --------------------&lt;BR /&gt;
             49&lt;BR /&gt;
ERROR: Invalid hexadecimal constant string "&amp;gt;&lt;TEST1 xxx="x.&amp;lt;br&amp;gt;
NOTE 49-169: The meaning of an identifier after a quoted string may change in a future SAS release.&amp;lt;br&amp;gt;
             Inserting white space between a quoted string and the succeeding identifier is&amp;lt;br&amp;gt;
             recommended.&amp;lt;br&amp;gt;
&amp;lt;br&amp;gt;
I am not using XML tools at this stage because this XML is application XML and nothing to do with any datasets.&amp;lt;br&amp;gt;
&amp;lt;br&amp;gt;
&amp;lt;br&amp;gt;
Thanks&amp;lt;br&amp;gt;
Lee"&gt;&lt;/TEST1&gt;</description>
    <pubDate>Mon, 18 Oct 2010 16:02:12 GMT</pubDate>
    <dc:creator>LeeJenson</dc:creator>
    <dc:date>2010-10-18T16:02:12Z</dc:date>
    <item>
      <title>Need to remove double quotes but leave the original ones already in data?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-to-remove-double-quotes-but-leave-the-original-ones-already/m-p/18376#M3594</link>
      <description>Hi, &lt;BR /&gt;
&lt;BR /&gt;
I am using the following code to export data to remove the header from &lt;BR /&gt;
the output file. My objective is to insert some XML into a little &lt;BR /&gt;
table and export the data into a file (noheader). &lt;BR /&gt;
&lt;BR /&gt;
proc sql; &lt;BR /&gt;
create create table test1; &lt;BR /&gt;
(xml char(500) &lt;BR /&gt;
); &lt;BR /&gt;
quit &lt;BR /&gt;
&lt;BR /&gt;
proc sql; &lt;BR /&gt;
insert into test1 &lt;BR /&gt;
set xml='&lt;XXXXX yyyyyy="ALL"&gt;'; &lt;BR /&gt;
quit; &lt;BR /&gt;
&lt;BR /&gt;
filename exTemp temp; &lt;BR /&gt;
proc export data=test2 outfile=exTemp dbms=csv; &lt;BR /&gt;
run; &lt;BR /&gt;
&lt;BR /&gt;
data _null_; &lt;BR /&gt;
 infile extemp firstobs=2; &lt;BR /&gt;
file "c:\test.xml"; &lt;BR /&gt;
input; &lt;BR /&gt;
put _infile_; &lt;BR /&gt;
run; &lt;BR /&gt;
&lt;BR /&gt;
This produces an output file like this &lt;BR /&gt;
&lt;BR /&gt;
"&lt;XXXX yyyyyy="" all=""&gt;" &lt;BR /&gt;
&lt;BR /&gt;
and I need the output to look like the original &lt;BR /&gt;
&lt;BR /&gt;
&lt;XXXX yyyyyy="ALL"&gt; &lt;BR /&gt;
&lt;BR /&gt;
Please could someone assist please. &lt;BR /&gt;
&lt;BR /&gt;
PS: If I am going about this all the wrong way then please let me &lt;BR /&gt;
know also. &lt;BR /&gt;
&lt;BR /&gt;
Thank You &lt;BR /&gt;
&lt;BR /&gt;
Lee&lt;/XXXX&gt;&lt;/XXXX&gt;&lt;/XXXXX&gt;</description>
      <pubDate>Mon, 18 Oct 2010 11:51:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-to-remove-double-quotes-but-leave-the-original-ones-already/m-p/18376#M3594</guid>
      <dc:creator>LeeJenson</dc:creator>
      <dc:date>2010-10-18T11:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: Need to remove double quotes but leave the original ones already in data?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-to-remove-double-quotes-but-leave-the-original-ones-already/m-p/18377#M3595</link>
      <description>I'm just curious why you're not using the XML libname engine or the DATA step to write what you want.&lt;BR /&gt;
 &lt;BR /&gt;
[pre]&lt;BR /&gt;
data _null_;&lt;BR /&gt;
  file 'c:\temp\fakexml.xml';&lt;BR /&gt;
  put @1 '&lt;XXXXX yyyyyy="ALL"&gt;';&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                         &lt;BR /&gt;
If you look at the file, c:\temp\fakexml.xml with Notepad, you will see your one line without extra quotes and without any header. FYI, your initially posted SQL has several syntax issues that should be producing errors in your SAS log (2 CREATE keywords and semi-colon in the wrong place).&lt;BR /&gt;
            &lt;BR /&gt;
You say you want to insert some XML into a "little table" -- is that little table in CSV format??? How did you create the table? What does it look like? It is possible in a DATA step program to write a line only 1 time (such as at the top of a file) but you haven't provided much information to go on.&lt;BR /&gt;
                &lt;BR /&gt;
cynthia&lt;/XXXXX&gt;</description>
      <pubDate>Mon, 18 Oct 2010 14:57:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-to-remove-double-quotes-but-leave-the-original-ones-already/m-p/18377#M3595</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-10-18T14:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: Need to remove double quotes but leave the original ones already in data?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-to-remove-double-quotes-but-leave-the-original-ones-already/m-p/18378#M3596</link>
      <description>Thanks for the reply. &lt;BR /&gt;
&lt;BR /&gt;
You say you want to insert some XML into a "little table" -- is that little table in CSV format??? &lt;BR /&gt;
Lee&amp;gt;The source table contained one variable and one record. The xml string is hardcoded apart from one bit,which is a variable.&lt;BR /&gt;
&lt;BR /&gt;
How did you create the table? &lt;BR /&gt;
Lee&amp;gt;I create the table in the code attached. Just one column, one record.&lt;BR /&gt;
&lt;BR /&gt;
Your programmed worked &lt;BR /&gt;
6912  data _null_;&lt;BR /&gt;
6913  file "C:\temp\test.xml";&lt;BR /&gt;
6914  put @1 '&lt;TEST&gt;&lt;TESTDO yyy="abc"&gt;&lt;TEST1 xxx="x"&gt;xyz&lt;/TEST1&gt;&lt;/TESTDO&gt;&lt;/TEST&gt;';&lt;BR /&gt;
6915  run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: The file "C:\temp\test.xml" is:&lt;BR /&gt;
      File Name=C:\temp\test.xml,&lt;BR /&gt;
      RECFM=V,LRECL=256&lt;BR /&gt;
&lt;BR /&gt;
NOTE: 1 record was written to the file "C:\temp\test.xml".&lt;BR /&gt;
&lt;BR /&gt;
But when I change it to support variable input and change the outside quotes to double quotes it has a problem with this solution.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
6916  %let test=abc;&lt;BR /&gt;
6917  data _null_;&lt;BR /&gt;
6918  file "C:\temp\test.xml";&lt;BR /&gt;
6919  put @1 "&lt;TEST&gt;&lt;TESTDO yyy="abc"&gt;&lt;TEST1 xxx="x"&gt;&amp;amp;test.&lt;/TEST1&gt;&lt;/TESTDO&gt;&lt;/TEST&gt;";&lt;BR /&gt;
             --------------------&lt;BR /&gt;
             49&lt;BR /&gt;
ERROR: Invalid hexadecimal constant string "&amp;gt;&lt;TEST1 xxx="x.&amp;lt;br&amp;gt;
NOTE 49-169: The meaning of an identifier after a quoted string may change in a future SAS release.&amp;lt;br&amp;gt;
             Inserting white space between a quoted string and the succeeding identifier is&amp;lt;br&amp;gt;
             recommended.&amp;lt;br&amp;gt;
&amp;lt;br&amp;gt;
I am not using XML tools at this stage because this XML is application XML and nothing to do with any datasets.&amp;lt;br&amp;gt;
&amp;lt;br&amp;gt;
&amp;lt;br&amp;gt;
Thanks&amp;lt;br&amp;gt;
Lee"&gt;&lt;/TEST1&gt;</description>
      <pubDate>Mon, 18 Oct 2010 16:02:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-to-remove-double-quotes-but-leave-the-original-ones-already/m-p/18378#M3596</guid>
      <dc:creator>LeeJenson</dc:creator>
      <dc:date>2010-10-18T16:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: Need to remove double quotes but leave the original ones already in data?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-to-remove-double-quotes-but-leave-the-original-ones-already/m-p/18379#M3597</link>
      <description>Hi:&lt;BR /&gt;
  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.&lt;BR /&gt;
&lt;BR /&gt;
This program&lt;BR /&gt;
[pre]&lt;BR /&gt;
%let test=abc;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
  file 'c:\temp\fakexml.xml';&lt;BR /&gt;
  put @1 '&lt;TEST&gt;&lt;TESTDO yyy="abc"&gt;&lt;TEST1 xxx="x"&gt;' &lt;BR /&gt;
         "&amp;amp;test.&lt;/TEST1&gt;&lt;/TESTDO&gt;&lt;/TEST&gt;";&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                         &lt;BR /&gt;
produces this outout in the c:\temp\fakexml.xml file:&lt;BR /&gt;
[pre]&lt;BR /&gt;
&amp;lt;test&amp;gt;&amp;lt;testdo yyy="abc"&amp;gt;&amp;lt;test1 xxx="x"&amp;gt;abc&amp;lt;/test1&amp;gt;&amp;lt;/testdo&amp;gt;&amp;lt;/test&amp;gt;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                              &lt;BR /&gt;
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):&lt;BR /&gt;
[pre]&lt;BR /&gt;
. . . more code . . .&lt;BR /&gt;
  put '** Another example';&lt;BR /&gt;
  put @1 '&amp;lt;wombat&amp;gt;'&lt;BR /&gt;
         "&amp;amp;test"&lt;BR /&gt;
         '&amp;lt;test1 koala="' "&amp;amp;test&amp;amp;test" '"&amp;gt;wombat&amp;lt;/test1&amp;gt;';&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                                    &lt;BR /&gt;
to produce this output in the file created by the PUT statements:&lt;BR /&gt;
[pre]&lt;BR /&gt;
** Another example&lt;BR /&gt;
&amp;lt;wombat&amp;gt;abc&amp;lt;test1 koala="abcabc"&amp;gt;wombat&amp;lt;/test1&amp;gt;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                   &lt;BR /&gt;
Log from the complete program is shown below.&lt;BR /&gt;
cynthia&lt;BR /&gt;
 &lt;BR /&gt;
[pre]&lt;BR /&gt;
88   %let test=abc;&lt;BR /&gt;
89   data _null_;&lt;BR /&gt;
90     file 'c:\temp\fakexml.xml';&lt;BR /&gt;
91     put @1 '&amp;lt;test&amp;gt;&amp;lt;testdo yyy="abc"&amp;gt;&amp;lt;test1 xxx="x"&amp;gt;'&lt;BR /&gt;
92            "&amp;amp;test.&amp;lt;/test1&amp;gt;&amp;lt;/testdo&amp;gt;&amp;lt;/test&amp;gt;";&lt;BR /&gt;
93&lt;BR /&gt;
94     put '** Another example';&lt;BR /&gt;
95     put @1 '&amp;lt;wombat&amp;gt;'&lt;BR /&gt;
96            "&amp;amp;test"&lt;BR /&gt;
97            '&amp;lt;test1 koala="' "&amp;amp;test&amp;amp;test" '"&amp;gt;wombat&amp;lt;/test1&amp;gt;';&lt;BR /&gt;
98   run;&lt;BR /&gt;
                      &lt;BR /&gt;
NOTE: The file 'c:\temp\fakexml.xml' is:&lt;BR /&gt;
      Filename=c:\temp\fakexml.xml,&lt;BR /&gt;
      RECFM=V,LRECL=256,File Size (bytes)=0,&lt;BR /&gt;
      Last Modified=18Oct2010:10:13:41,&lt;BR /&gt;
      Create Time=18Oct2010:08:52:49&lt;BR /&gt;
                        &lt;BR /&gt;
NOTE: 3 records were written to the file 'c:\temp\fakexml.xml'.&lt;BR /&gt;
      The minimum record length was 18.&lt;BR /&gt;
      The maximum record length was 66.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.03 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
[/pre]</description>
      <pubDate>Mon, 18 Oct 2010 16:22:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-to-remove-double-quotes-but-leave-the-original-ones-already/m-p/18379#M3597</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-10-18T16:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: Need to remove double quotes but leave the original ones already in data?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-to-remove-double-quotes-but-leave-the-original-ones-already/m-p/18380#M3598</link>
      <description>This was the perfect solution for me &lt;BR /&gt;
&lt;BR /&gt;
%let test=abc;data _null_;  &lt;BR /&gt;
file 'c:\temp\fakexml.xml';  &lt;BR /&gt;
put @1 '&lt;TEST&gt;&lt;TESTDO yyy="abc"&gt;&lt;TEST1 xxx="x"&gt;'          &lt;BR /&gt;
"&amp;amp;test.&lt;/TEST1&gt;&lt;/TESTDO&gt;&lt;/TEST&gt;";&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
thank you 5 million times&lt;BR /&gt;
&lt;BR /&gt;
Lee</description>
      <pubDate>Mon, 18 Oct 2010 17:06:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-to-remove-double-quotes-but-leave-the-original-ones-already/m-p/18380#M3598</guid>
      <dc:creator>LeeJenson</dc:creator>
      <dc:date>2010-10-18T17:06:37Z</dc:date>
    </item>
  </channel>
</rss>

