<?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 How to replace embedded double quotes in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-embedded-double-quotes-in-SAS/m-p/956110#M373366</link>
    <description>&lt;P&gt;I have a text with embedded double quotes and a JSON file has to be created. The file has the double quotes between text&amp;nbsp; but while loading this file, the process fails as the parsing is not working. I would like to replace starting double quotes with \" and ending double quotes with \".&lt;/P&gt;&lt;P&gt;e.g. Original&amp;nbsp; text -&amp;gt;&amp;nbsp;&lt;STRONG&gt;Is a "new" version&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Replaced text (desired) -&amp;gt;&amp;nbsp;&lt;STRONG&gt;Is a \"new\" version&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Once the text is modified the JSON file can parse the embedded quotes.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Jan 2025 19:09:30 GMT</pubDate>
    <dc:creator>vibhas</dc:creator>
    <dc:date>2025-01-14T19:09:30Z</dc:date>
    <item>
      <title>How to replace embedded double quotes in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-embedded-double-quotes-in-SAS/m-p/956110#M373366</link>
      <description>&lt;P&gt;I have a text with embedded double quotes and a JSON file has to be created. The file has the double quotes between text&amp;nbsp; but while loading this file, the process fails as the parsing is not working. I would like to replace starting double quotes with \" and ending double quotes with \".&lt;/P&gt;&lt;P&gt;e.g. Original&amp;nbsp; text -&amp;gt;&amp;nbsp;&lt;STRONG&gt;Is a "new" version&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Replaced text (desired) -&amp;gt;&amp;nbsp;&lt;STRONG&gt;Is a \"new\" version&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Once the text is modified the JSON file can parse the embedded quotes.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 19:09:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-embedded-double-quotes-in-SAS/m-p/956110#M373366</guid>
      <dc:creator>vibhas</dc:creator>
      <dc:date>2025-01-14T19:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace embedded double quotes in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-embedded-double-quotes-in-SAS/m-p/956133#M373377</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/472127"&gt;@vibhas&lt;/a&gt;! There are many ways to achieve this, both inside and outside of SAS. Can you describe where your process is failing? Can you post your code and error message?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 20:58:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-embedded-double-quotes-in-SAS/m-p/956133#M373377</guid>
      <dc:creator>Stu_SAS</dc:creator>
      <dc:date>2025-01-14T20:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace embedded double quotes in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-embedded-double-quotes-in-SAS/m-p/956134#M373378</link>
      <description>&lt;P&gt;The problem is that a JSON file has a LOT of quotes already, so you need to be able to find the ones that are inside and so need to be protected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you share two small example JSON files that represents what have now and what you want to create?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also it&amp;nbsp;is not clear to me if you are writing the JSON file using SAS or&amp;nbsp;reading the JSON file using SAS?&amp;nbsp;&amp;nbsp;Or perhaps you have an existing JSON file you just want to use SAS to process so it can be read by something else?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In SAS an embedded quote should be represented by doubled quotes.&amp;nbsp; So to represent the string:&lt;/P&gt;
&lt;PRE&gt;Is a "new" version&lt;/PRE&gt;
&lt;P&gt;You would use this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"Is a ""new"" version"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But in the Unix command shell style that JSON uses you would instead "escape" the special characters with a backslash so that you would use this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"Is a \"new\" version"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you have the "" already then you just want to change the "" to \" instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But might need special logic to handle the cases where the inside quote is at the start or end of the string.&amp;nbsp; You want something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"""Hello"""&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Converted to&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"\"Hello\""&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And not one of these instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;\""Hello\""
"\"Hello"\"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 22:21:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-embedded-double-quotes-in-SAS/m-p/956134#M373378</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-01-14T22:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace embedded double quotes in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-embedded-double-quotes-in-SAS/m-p/956136#M373379</link>
      <description>&lt;P&gt;This may get you started - I don't have a JSON Access engine on my machine, but would a simple TRANWRD or PRXCHANGE function in Perl do the job?&amp;nbsp; &amp;nbsp;Again, this is basic but maybe??&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="donricardo_0-1736890942857.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103719i40CF5C710C89157A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="donricardo_0-1736890942857.png" alt="donricardo_0-1736890942857.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 21:42:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-embedded-double-quotes-in-SAS/m-p/956136#M373379</guid>
      <dc:creator>donricardo</dc:creator>
      <dc:date>2025-01-14T21:42:34Z</dc:date>
    </item>
  </channel>
</rss>

