<?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: how to concatenate &amp;quot;)&amp;quot; in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-concatenate-quot-quot/m-p/842086#M332974</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/111564"&gt;@HitmonTran&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for marking my solution correct, but since then I have withdrawn my solution in favor of the solution from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;which in my opinion is clearly a better solution. Would you be kind enough to mark Patrick's answer as correct?&lt;/P&gt;</description>
    <pubDate>Wed, 02 Nov 2022 13:20:58 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-11-02T13:20:58Z</dc:date>
    <item>
      <title>how to concatenate ")"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-concatenate-quot-quot/m-p/841342#M332669</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how do I add a ")" at the end of the variable if it's missing a ")"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data:&lt;/P&gt;&lt;P&gt;var&lt;/P&gt;&lt;P&gt;(100.00%&lt;/P&gt;&lt;P&gt;(99.0%)&lt;/P&gt;&lt;P&gt;(10.00%)&lt;/P&gt;&lt;P&gt;(5.55%)&lt;/P&gt;&lt;P&gt;(99%&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;want:&lt;/P&gt;&lt;P&gt;(100.00%)&lt;/P&gt;&lt;P&gt;(99.0%)&lt;/P&gt;&lt;P&gt;(10.00%)&lt;/P&gt;&lt;P&gt;(5.55%)&lt;/P&gt;&lt;P&gt;(99%)&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2022 16:40:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-concatenate-quot-quot/m-p/841342#M332669</guid>
      <dc:creator>HitmonTran</dc:creator>
      <dc:date>2022-10-28T16:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to concatenate ")"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-concatenate-quot-quot/m-p/841346#M332672</link>
      <description>&lt;P&gt;If these are text strings, this ought to work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input string $12.;
    cards;
(100.00%
(99.0%)
(10.00%)
(5.55%)
(99%
;

data want;
    set have;
    if left(reverse(string)) ^=: ')' then string=cats(string,')');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note the &lt;A href="https://support.sas.com/kb/24/839.html" target="_self"&gt;colon modifier&lt;/A&gt; in the IF statement, this is important.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also important, if you data is arriving sometimes with right parentheses and sometimes without right parentheses, then your process needs to be fixed. In the long run, that is a much better solution than a band-aid like this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With regards to providing us with sample data,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/111564"&gt;@HitmonTran&lt;/a&gt;&amp;nbsp;please note and follow my lead in the future, the data is provided via &lt;FONT color="#FF0000"&gt;working&lt;/FONT&gt; SAS data step code, and not just by showing us a list.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2022 16:52:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-concatenate-quot-quot/m-p/841346#M332672</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-10-28T16:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to concatenate ")"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-concatenate-quot-quot/m-p/841347#M332673</link>
      <description>&lt;P&gt;Is the value supposed to represent a negative percentage?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the variable numeric or character? Proc Contents will help with this if you aren't exactly sure.&lt;/P&gt;
&lt;P&gt;If the existing variable has a length of 8&amp;nbsp; , implied from your value (100.00%, and is character then you will need to create a new variable as there is not enough enough space to insert the character.&lt;/P&gt;
&lt;P&gt;How exactly is the value created? That would be the place to address this instead of "fixing" later. Show the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best is to provide example data in the form of a data step so we know exactly what we are dealing with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2022 20:02:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-concatenate-quot-quot/m-p/841347#M332673</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-28T20:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: how to concatenate ")"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-concatenate-quot-quot/m-p/841410#M332705</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/111564"&gt;@HitmonTran&lt;/a&gt;&amp;nbsp;Based on below sample code it appears that informat PERCENT can deal with such source data.&lt;/P&gt;
&lt;P&gt;If the parenthesis mean minus percent values then I'd keep the numerical variable &lt;EM&gt;num_var&lt;/EM&gt; for further processing.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
  input string $12.;
  format num_var percent9.2;
  num_var=input(string,percent9.);
  str_var=compress(put(num_var,percent9.2));
  datalines;
(100.00%
(99.0%)
(10.00%)
(5.55%)
(99%
25.56%
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1667010542325.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76737iC6B247AA93735CF0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1667010542325.png" alt="Patrick_0-1667010542325.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Oct 2022 02:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-concatenate-quot-quot/m-p/841410#M332705</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-10-29T02:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to concatenate ")"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-concatenate-quot-quot/m-p/841435#M332718</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input string $12.;
    cards;
(100.00%
(99.0%)
(10.00%)
(5.55%)
(99%
;

data want;
    set have;
    if not findc(string,')') then string=cats(string,')');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 29 Oct 2022 09:55:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-concatenate-quot-quot/m-p/841435#M332718</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-10-29T09:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to concatenate ")"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-concatenate-quot-quot/m-p/841442#M332724</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt; says:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;If the parenthesis mean minus percent values then I'd keep the numerical variable &lt;EM&gt;num_var&lt;/EM&gt; for further processing.&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I agree, that's a much better solution than handling percents as character strings. And so, I'd like to withdraw my solution above.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Oct 2022 13:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-concatenate-quot-quot/m-p/841442#M332724</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-10-29T13:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to concatenate ")"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-concatenate-quot-quot/m-p/842086#M332974</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/111564"&gt;@HitmonTran&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for marking my solution correct, but since then I have withdrawn my solution in favor of the solution from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;which in my opinion is clearly a better solution. Would you be kind enough to mark Patrick's answer as correct?&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 13:20:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-concatenate-quot-quot/m-p/842086#M332974</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-02T13:20:58Z</dc:date>
    </item>
  </channel>
</rss>

