<?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 using cats function with an apostrophe in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/using-cats-function-with-an-apostrophe/m-p/876530#M42989</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using a cats function to generate one json record (see the code below).&amp;nbsp; But the cats function failed when there is an apostrophe either in the first name or last Name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do we solve that issue ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ex last Name = D'agostina&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data ConsentInfo&amp;amp;j.;
length record $4000;
set info_1;
i=_n_;
record=cats("'", '{ "firstName" : ',' "',firstName,'", ',' "lastName" : ','"',lastName,'", ','"email" :',
'"',email,'"}',"'");
call symputx(cats('NewRec',i),record,'g');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 18 May 2023 18:12:59 GMT</pubDate>
    <dc:creator>alepage</dc:creator>
    <dc:date>2023-05-18T18:12:59Z</dc:date>
    <item>
      <title>using cats function with an apostrophe</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/using-cats-function-with-an-apostrophe/m-p/876530#M42989</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using a cats function to generate one json record (see the code below).&amp;nbsp; But the cats function failed when there is an apostrophe either in the first name or last Name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do we solve that issue ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ex last Name = D'agostina&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data ConsentInfo&amp;amp;j.;
length record $4000;
set info_1;
i=_n_;
record=cats("'", '{ "firstName" : ',' "',firstName,'", ',' "lastName" : ','"',lastName,'", ','"email" :',
'"',email,'"}',"'");
call symputx(cats('NewRec',i),record,'g');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 May 2023 18:12:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/using-cats-function-with-an-apostrophe/m-p/876530#M42989</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2023-05-18T18:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: using cats function with an apostrophe</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/using-cats-function-with-an-apostrophe/m-p/876533#M42990</link>
      <description>&lt;P&gt;Don't try to add the quotes yourself.&amp;nbsp; Use the QUOTE() function to properly add the quotes around a string.&amp;nbsp; That will properly double up any quotes that are in the string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the optional second argument when you want it to use single quotes instead of the default double quotes.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;record=quote(cats('{ "firstName":',quote(trim(firstname))
                 ,',"lastName":',quote(trim(lastName))
                 ,',"email" :',quote(trim(email))
                 ,'}')
      ,"'");&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 May 2023 18:26:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/using-cats-function-with-an-apostrophe/m-p/876533#M42990</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-18T18:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: using cats function with an apostrophe</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/using-cats-function-with-an-apostrophe/m-p/876554#M42991</link>
      <description>&lt;P&gt;By doing that, for example instead of seeing D'agostina, we will have D ' ' Agostina and the cats function will take it.&amp;nbsp; However at the end, when this lastName will be sent to an API Web Site, the lastName will look like as D ' ' Agostina instead of D'agostina.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there another work around solution ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 19:53:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/using-cats-function-with-an-apostrophe/m-p/876554#M42991</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2023-05-18T19:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: using cats function with an apostrophe</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/using-cats-function-with-an-apostrophe/m-p/876556#M42992</link>
      <description>&lt;P&gt;You will need to show the full code to see whether or not that is true.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In normal SAS code that is NOT what will happen.&amp;nbsp; Try it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  name="D'Agostina";
  string1=cats('{"name":',quote(trim(name)),'}');
  qstring=quote(trim(string1),"'");
  call symputx('mvar',qstring);
run;

data test2 ;
 set test;
 string2=&amp;amp;mvar;
 put (_all_) (=/);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 May 2023 20:06:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/using-cats-function-with-an-apostrophe/m-p/876556#M42992</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-18T20:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: using cats function with an apostrophe</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/using-cats-function-with-an-apostrophe/m-p/876561#M42994</link>
      <description>&lt;P&gt;If you are doing this to create JSON output why are you sticking values into a macro variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And did you try the Libname JSON engine to create JSON files?&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 20:30:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/using-cats-function-with-an-apostrophe/m-p/876561#M42994</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-18T20:30:48Z</dc:date>
    </item>
  </channel>
</rss>

