<?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: Adding quotation marks to strings then joining them with comma in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Adding-quotation-marks-to-strings-then-joining-them-with-comma/m-p/490502#M72115</link>
    <description>&lt;P&gt;Thanks, Reeza, for your valuable response!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your suggested code made it easy for me to digest the next suggestions!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciated!&lt;/P&gt;</description>
    <pubDate>Tue, 28 Aug 2018 15:02:33 GMT</pubDate>
    <dc:creator>Treeva</dc:creator>
    <dc:date>2018-08-28T15:02:33Z</dc:date>
    <item>
      <title>Adding quotation marks to strings then joining them with comma</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-quotation-marks-to-strings-then-joining-them-with-comma/m-p/490475#M72108</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on two character variables where I need to&amp;nbsp;do the following with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First:&amp;nbsp;add double quotation marks to the strings of both of them, for example:&lt;/P&gt;&lt;P&gt;var1 :&amp;nbsp;Q11.0&amp;nbsp; &amp;nbsp; Q11.1&amp;nbsp; &amp;nbsp;to become&amp;nbsp; "&lt;SPAN&gt;Q11.0"&amp;nbsp; &amp;nbsp; "&lt;/SPAN&gt;&lt;SPAN&gt;Q11.1"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;var2:&amp;nbsp; &amp;nbsp;Q110&amp;nbsp; &amp;nbsp;&amp;nbsp;Q111&amp;nbsp; &amp;nbsp;to become&amp;nbsp; "Q110"&amp;nbsp; &amp;nbsp; "Q111"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Second: Join each line&amp;nbsp;strings from both variables by commas, for example:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var_all:&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;Q11.0",&amp;nbsp;"Q110"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"Q11.1" ,&amp;nbsp;"Q111" &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there a one-statement function in SAS that can give me the attempted result?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks so much for your helpful tips in advance!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Treeva&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 14:25:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-quotation-marks-to-strings-then-joining-them-with-comma/m-p/490475#M72108</guid>
      <dc:creator>Treeva</dc:creator>
      <dc:date>2018-08-28T14:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: Adding quotation marks to strings then joining them with comma</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-quotation-marks-to-strings-then-joining-them-with-comma/m-p/490478#M72109</link>
      <description>&lt;P&gt;Please post test data in the form of a datastep in future.&amp;nbsp; As such this is not tested:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  length want $2000;
  want=cat('"',tranwrd(var1," ",'","'),'"'," ",'"',tranwrd(var2," ",'","'),'"'");
run;&lt;/PRE&gt;
&lt;P&gt;So effectively replace the space in each variable with quote comma quote, and then cat this with a quote before and after.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 14:33:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-quotation-marks-to-strings-then-joining-them-with-comma/m-p/490478#M72109</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-28T14:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: Adding quotation marks to strings then joining them with comma</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-quotation-marks-to-strings-then-joining-them-with-comma/m-p/490482#M72110</link>
      <description>The QUOTE() function will enclose the value in quotes. The CATX() will combine them. It does depend a bit on how your data is structured but something like the following:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Y = catx(', ', quote(var1), quote(var2));&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Aug 2018 14:38:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-quotation-marks-to-strings-then-joining-them-with-comma/m-p/490482#M72110</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-28T14:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: Adding quotation marks to strings then joining them with comma</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-quotation-marks-to-strings-then-joining-them-with-comma/m-p/490487#M72112</link>
      <description>&lt;P&gt;The best is to try regular expressions but&amp;nbsp;that syntax&lt;U&gt; hurts&lt;/U&gt; my eye. If&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;the genius, has the time and wishes to help&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 14:44:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-quotation-marks-to-strings-then-joining-them-with-comma/m-p/490487#M72112</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-08-28T14:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: Adding quotation marks to strings then joining them with comma</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-quotation-marks-to-strings-then-joining-them-with-comma/m-p/490492#M72113</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;The QUOTE() function will enclose the value in quotes. The CATX() will combine them. It does depend a bit on how your data is structured but something like the following:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Y = catx(', ', quote(var1), quote(var2));&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And depending on the assigned length and actual values of the variables you may need to remove trailing blanks before using the QUOTE function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Y = catx(', ', quote(strip(var1)), quote(strip(var2)) );&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 14:53:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-quotation-marks-to-strings-then-joining-them-with-comma/m-p/490492#M72113</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-28T14:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: Adding quotation marks to strings then joining them with comma</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-quotation-marks-to-strings-then-joining-them-with-comma/m-p/490500#M72114</link>
      <description>&lt;P&gt;Thanks RW2 for your prompt response!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll make sure in the future to post a test data in the future, so it can be tested.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I followed your instructions regarding doing the replacement according to my own case, but unfortunately it didn't work! probably it was my fault!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciated&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 15:00:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-quotation-marks-to-strings-then-joining-them-with-comma/m-p/490500#M72114</guid>
      <dc:creator>Treeva</dc:creator>
      <dc:date>2018-08-28T15:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: Adding quotation marks to strings then joining them with comma</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-quotation-marks-to-strings-then-joining-them-with-comma/m-p/490502#M72115</link>
      <description>&lt;P&gt;Thanks, Reeza, for your valuable response!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your suggested code made it easy for me to digest the next suggestions!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciated!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 15:02:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-quotation-marks-to-strings-then-joining-them-with-comma/m-p/490502#M72115</guid>
      <dc:creator>Treeva</dc:creator>
      <dc:date>2018-08-28T15:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: Adding quotation marks to strings then joining them with comma</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-quotation-marks-to-strings-then-joining-them-with-comma/m-p/490504#M72117</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks, novinosrin, for stopping by &amp;amp; inviting another user to give a hand here!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Appreciated!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 15:05:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-quotation-marks-to-strings-then-joining-them-with-comma/m-p/490504#M72117</guid>
      <dc:creator>Treeva</dc:creator>
      <dc:date>2018-08-28T15:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Adding quotation marks to strings then joining them with comma</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-quotation-marks-to-strings-then-joining-them-with-comma/m-p/490518#M72119</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code perfectly worked!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot, ballardw.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciated!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 15:28:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-quotation-marks-to-strings-then-joining-them-with-comma/m-p/490518#M72119</guid>
      <dc:creator>Treeva</dc:creator>
      <dc:date>2018-08-28T15:28:25Z</dc:date>
    </item>
  </channel>
</rss>

