<?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: Delete certain text in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Delete-certain-text/m-p/640504#M190802</link>
    <description>Optionally you could do:&lt;BR /&gt;`g[i] =scan( g[i], 1, '(' );`&lt;BR /&gt;&lt;BR /&gt;Bart</description>
    <pubDate>Thu, 16 Apr 2020 18:11:00 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2020-04-16T18:11:00Z</dc:date>
    <item>
      <title>Delete certain text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-certain-text/m-p/640497#M190798</link>
      <description>&lt;P&gt;I have the following table below. What I would like to do is that&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If category_1 = 'AAA' and category_2 = 'Yes' then Group_1 through Group_4 should delete '(100.0%)'.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="444"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="75"&gt;Category_1&lt;/TD&gt;
&lt;TD width="75"&gt;Category_2&lt;/TD&gt;
&lt;TD width="70"&gt;Group_1&lt;/TD&gt;
&lt;TD width="77"&gt;Group_2&lt;/TD&gt;
&lt;TD width="70"&gt;Group_3&lt;/TD&gt;
&lt;TD width="77"&gt;Group_4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;AAA&lt;/TD&gt;
&lt;TD&gt;Yes&lt;/TD&gt;
&lt;TD&gt;8 (100.0%)&lt;/TD&gt;
&lt;TD&gt;12 (100.0%)&lt;/TD&gt;
&lt;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TD&gt;2 (25.0%)&lt;/TD&gt;
&lt;TD&gt;6 (50.0%)&lt;/TD&gt;
&lt;TD&gt;1 (33.3%)&lt;/TD&gt;
&lt;TD&gt;10 (76.9%)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;BBB&lt;/TD&gt;
&lt;TD&gt;No&lt;/TD&gt;
&lt;TD&gt;6 (75.0%)&lt;/TD&gt;
&lt;TD&gt;6 (50.0%)&lt;/TD&gt;
&lt;TD&gt;2 (66.7%)&lt;/TD&gt;
&lt;TD&gt;3 (23.1%)&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not sure how to do it. I tried catx and strip&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2020 17:51:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-certain-text/m-p/640497#M190798</guid>
      <dc:creator>monday89</dc:creator>
      <dc:date>2020-04-16T17:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: Delete certain text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-certain-text/m-p/640500#M190799</link>
      <description>&lt;P&gt;You need to show us the actual SAS data set as SAS data step code, not some table representinng your data. We can't work with the tables you show.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The instructions to create a SAS data set as SAS data step code are here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;How to create a data step version of your data AKA generate sample data for forums&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2020 17:55:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-certain-text/m-p/640500#M190799</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-16T17:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: Delete certain text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-certain-text/m-p/640501#M190800</link>
      <description>&lt;P&gt;Maybe:&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   array g Group_1 - Group_4;
   if category_1 = 'AAA' and category_2= 'Yes' then do i=1 to dim(g);
      g[i] =tranwrd(g[i],'(100.0%)','');
   end;
   drop i;
run;&lt;/PRE&gt;
&lt;P&gt;Generally when the same thing is to be done to multiple variables then think Array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Personally I would likely go back to the step that created this marginally structured data and prevent the creation of such if at all possible. Putting 2 or more values into a single variable is quite often a difficult structure to work with.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2020 18:07:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-certain-text/m-p/640501#M190800</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-16T18:07:34Z</dc:date>
    </item>
    <item>
      <title>Re: Delete certain text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-certain-text/m-p/640504#M190802</link>
      <description>Optionally you could do:&lt;BR /&gt;`g[i] =scan( g[i], 1, '(' );`&lt;BR /&gt;&lt;BR /&gt;Bart</description>
      <pubDate>Thu, 16 Apr 2020 18:11:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-certain-text/m-p/640504#M190802</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-04-16T18:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: Delete certain text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-certain-text/m-p/640514#M190812</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Optionally you could do:&lt;BR /&gt;`g[i] =scan( g[i], 1, '(' );`&lt;BR /&gt;&lt;BR /&gt;Bart&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I thought of that but the OP doesn't say that all of the conditional variable values will always have the (100,0%).&lt;/P&gt;
&lt;P&gt;If the value(s) were (45.0%) then scan would remove those as well but I understood the request to only remove 100%.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2020 19:01:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-certain-text/m-p/640514#M190812</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-16T19:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: Delete certain text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-certain-text/m-p/640516#M190814</link>
      <description>&lt;P&gt;Hi. I tried the following:&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   array g Group_1 - Group_4;
   if category_1 = 'AAA' and category_2= 'Yes' then do i=1 to dim(g);
      &lt;SPAN&gt;g[i] =scan( g[i], 1, '(' );&lt;/SPAN&gt;
   end;
   drop i;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;but i am getting errors for&amp;nbsp;&amp;nbsp;'array g Group_1 - Group_4;' error message:&amp;nbsp; Missing numeric suffix on a numbered variable list&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2020 19:06:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-certain-text/m-p/640516#M190814</guid>
      <dc:creator>monday89</dc:creator>
      <dc:date>2020-04-16T19:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: Delete certain text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-certain-text/m-p/640517#M190815</link>
      <description>Good point.&lt;BR /&gt;Bart</description>
      <pubDate>Thu, 16 Apr 2020 19:09:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-certain-text/m-p/640517#M190815</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-04-16T19:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: Delete certain text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-certain-text/m-p/640518#M190816</link>
      <description>do you have variable named "Group_" in your data? &lt;BR /&gt;&lt;BR /&gt;Bart</description>
      <pubDate>Thu, 16 Apr 2020 19:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-certain-text/m-p/640518#M190816</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-04-16T19:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: Delete certain text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-certain-text/m-p/640519#M190817</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/303622"&gt;@monday89&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi. I tried the following:&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   array g Group_1 - Group_4;
   if category_1 = 'AAA' and category_2= 'Yes' then do i=1 to dim(g);
      &lt;SPAN&gt;g[i] =scan( g[i], 1, '(' );&lt;/SPAN&gt;
   end;
   drop i;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;but i am getting errors for&amp;nbsp;&amp;nbsp;'array g Group_1 - Group_4;' error message:&amp;nbsp; Missing numeric suffix on a numbered variable list&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your column headings show group_1 to 4. If those are not the variable names there is no way I can guess what the actual variables may be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2020 19:17:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-certain-text/m-p/640519#M190817</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-16T19:17:14Z</dc:date>
    </item>
  </channel>
</rss>

