<?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: Text String, Search and Replace, Contingent in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285168#M58253</link>
    <description>&lt;P&gt;OK. Clear Now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input x $40.;
cards;
1701_0-3101_1
1502a_1-1703_1
1703_1-1801_1
0101_1-1002_0
1205_1-1703_1
0501_1-1301_0
2401_0-3101_0
2006_0-3602_0
WXYZ_0-2803_0
LMNOP_0-2802_0
;
run;
data want;
 set have;
 temp=scan(x,1,'-');
 if char(temp,3)='0' then temp1=cats(substr(temp,1,2),substr(temp,4));
  else temp1=temp;
  
 temp=scan(x,2,'-');
 if char(temp,3)='0' then temp2=cats(substr(temp,1,2),substr(temp,4));
  else temp2=temp;

 want=catx('-',temp1,temp2);
 drop temp:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 18 Jul 2016 08:14:29 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-07-18T08:14:29Z</dc:date>
    <item>
      <title>Text String, Search and Replace, Contingent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285154#M58244</link>
      <description>&lt;P&gt;Here's the data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;17&lt;STRONG&gt;0&lt;/STRONG&gt;1_0-31&lt;STRONG&gt;0&lt;/STRONG&gt;1_1
1502a_1-1703_1
1703_1-1801_1
0101_1-1002_0
1205_1-1703_1
0501_1-1301_0
2401_0-3101_0
2006_0-3602_0
WXYZ_0-2803_0
LMNOP_0-2802_0
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Two related problems:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) &amp;nbsp;&lt;STRONG&gt;IFF&lt;/STRONG&gt; the third character over from the beginning is a &lt;STRONG&gt;ZERO&lt;/STRONG&gt;, then delete it (or at the very least, change it to a space -- for compress to then kill it).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) &amp;nbsp;IFF, &lt;STRONG&gt;following the dash&lt;/STRONG&gt;, the third character over from that is a ZERO, then delete it&amp;nbsp;&lt;SPAN&gt;(or at the very least, change it to a space -- for compress to then kill it)&lt;/SPAN&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Appears to be a lot easier said than done.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nicholas Kormanik&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 06:09:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285154#M58244</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2016-07-18T06:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: Text String, Search and Replace, Contingent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285155#M58245</link>
      <description>&lt;P&gt;Substr or char functions can help with your if conditions, they'll extract the character to be tested.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The scan function will help separate into parts before/after the dash.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Substr -left of- will allow you to replace the character.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I like to to find the functions I need by looking through the list, where it's listed by category.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/lefunctionsref/67960/HTML/default/viewer.htm#p0w6napahk6x0an0z2dzozh2ouzm.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/lefunctionsref/67960/HTML/default/viewer.htm#p0w6napahk6x0an0z2dzozh2ouzm.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 06:25:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285155#M58245</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-18T06:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: Text String, Search and Replace, Contingent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285156#M58246</link>
      <description>&lt;P&gt;Thanks Reeza.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've been experimenting with the Substr, as it seems closest to being able to solve these. &amp;nbsp;So far, nothing works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My hunch is, time to study &lt;STRONG&gt;regular expressions&lt;/STRONG&gt; a lot more. &amp;nbsp;And find out how to use those in SAS. &amp;nbsp;Probably a short string of that would do the trick.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 06:47:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285156#M58246</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2016-07-18T06:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: Text String, Search and Replace, Contingent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285158#M58247</link>
      <description>&lt;P&gt;Follow what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;said . It is good for you to solve it on your own .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input x $40.;
cards;
1701_0-3101_1
1502a_1-1703_1
1703_1-1801_1
0101_1-1002_0
1205_1-1703_1
0501_1-1301_0
2401_0-3101_0
2006_0-3602_0
WXYZ_0-2803_0
LMNOP_0-2802_0
;
run;
data want;
 set have;
 if char(scan(x,1,'-'),3)='0' or 
    char(scan(x,2,'-'),3)='0' then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jul 2016 07:00:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285158#M58247</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-18T07:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: Text String, Search and Replace, Contingent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285159#M58248</link>
      <description>&lt;P&gt;But daaaad.....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Error message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;The data set WORK.WANT has 0 observations and 1 variables.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As said, seems pretty hard.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 07:19:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285159#M58248</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2016-07-18T07:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: Text String, Search and Replace, Contingent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285160#M58249</link>
      <description>&lt;P&gt;That is what supposed to be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You didn't post the output you need . So I guess you want OR .Try AND .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt; set have;&lt;BR /&gt; if char(scan(x,1,'-'),3)='0' &lt;STRONG&gt;and&lt;/STRONG&gt;&lt;BR /&gt; char(scan(x,2,'-'),3)='0' then delete;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 07:22:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285160#M58249</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-18T07:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: Text String, Search and Replace, Contingent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285166#M58252</link>
      <description>&lt;P&gt;Say what??!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did too. &amp;nbsp;Delete!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the desired result (using a silly simple text editor):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;171_0-311_1
152a_1-173_1
173_1-181_1
011_1-102_0
125_1-173_1
051_1-131_0
241_0-311_0
206_0-362_0
WXYZ_0-283_0
LMNOP_0-282_0
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Whaddya think?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No need to do all in one step, by the way. &amp;nbsp;Just do one at a time. Two separate steps? Even a partial achievement would be a plus.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 07:54:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285166#M58252</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2016-07-18T07:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Text String, Search and Replace, Contingent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285168#M58253</link>
      <description>&lt;P&gt;OK. Clear Now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input x $40.;
cards;
1701_0-3101_1
1502a_1-1703_1
1703_1-1801_1
0101_1-1002_0
1205_1-1703_1
0501_1-1301_0
2401_0-3101_0
2006_0-3602_0
WXYZ_0-2803_0
LMNOP_0-2802_0
;
run;
data want;
 set have;
 temp=scan(x,1,'-');
 if char(temp,3)='0' then temp1=cats(substr(temp,1,2),substr(temp,4));
  else temp1=temp;
  
 temp=scan(x,2,'-');
 if char(temp,3)='0' then temp2=cats(substr(temp,1,2),substr(temp,4));
  else temp2=temp;

 want=catx('-',temp1,temp2);
 drop temp:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jul 2016 08:14:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285168#M58253</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-18T08:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: Text String, Search and Replace, Contingent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285184#M58257</link>
      <description>&lt;P&gt;Delete was ambiguous, could mean the observation or character.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 09:42:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285184#M58257</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-18T09:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: Text String, Search and Replace, Contingent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285261#M58275</link>
      <description>&lt;P&gt;Or using PRX functions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input x $40.;
cards;
1701_0-3101_1
1502a_1-1703_1
1703_1-1801_1
0101_1-1002_0
1205_1-1703_1
0501_1-1301_0
2401_0-3101_0
2006_0-3602_0
WXYZ_0-2803_0
LMNOP_0-2802_0
;
run;


data want;
set have;
x1=prxchange('s/(?&amp;lt;=^\w{2})0|(?&amp;lt;=-\w{2})0//oi',-1,x);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jul 2016 15:50:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285261#M58275</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-07-18T15:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: Text String, Search and Replace, Contingent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285433#M58353</link>
      <description>&lt;P&gt;Xia Keshan, you da man! Wonderful work. I owe you, big time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For that you can have ALL of the South China Sea. Except for what Haikuo wants (see post further below).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hey, by chance do you happen to have a sister that's not married that you could introduce me to?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nicholas&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2016 04:16:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285433#M58353</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2016-07-19T04:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: Text String, Search and Replace, Contingent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285434#M58354</link>
      <description>&lt;P&gt;Wow!! &amp;nbsp;What magic is this??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So little code. &amp;nbsp;Such instant amazing results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How'd you do that??!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Really, yours is a fantastic solution, as is Ksharp's above. &amp;nbsp;I'll give Ksharp the edge only because no one in the world will understand your solution, even though it works perfectly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Much thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nicholas&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2016 04:27:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285434#M58354</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2016-07-19T04:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: Text String, Search and Replace, Contingent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285524#M58395</link>
      <description>&lt;P&gt;Well, you are not the only one, I am with you. I&amp;nbsp;refuse to&amp;nbsp;read it after I write it &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;. You know what they say about Perl Regular Expression? OK to write, Hard to read.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2016 13:59:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Text-String-Search-and-Replace-Contingent/m-p/285524#M58395</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-07-19T13:59:59Z</dc:date>
    </item>
  </channel>
</rss>

