<?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 Find and Replace a word in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627163#M185066</link>
    <description>Replace from one word to another word in a long string of more than 200 characters</description>
    <pubDate>Tue, 25 Feb 2020 12:36:51 GMT</pubDate>
    <dc:creator>Nira</dc:creator>
    <dc:date>2020-02-25T12:36:51Z</dc:date>
    <item>
      <title>Find and Replace a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627163#M185066</link>
      <description>Replace from one word to another word in a long string of more than 200 characters</description>
      <pubDate>Tue, 25 Feb 2020 12:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627163#M185066</guid>
      <dc:creator>Nira</dc:creator>
      <dc:date>2020-02-25T12:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627164#M185067</link>
      <description>Can anybody help to solve ? Since TRANWRD function limits to only 200 characters. Thanks</description>
      <pubDate>Tue, 25 Feb 2020 12:41:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627164#M185067</guid>
      <dc:creator>Nira</dc:creator>
      <dc:date>2020-02-25T12:41:15Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627165#M185068</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/313767"&gt;@Nira&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;Maybe you can try to use a pearl regular expression :&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Var2 = Prxchange('s/ /*expr to find*/ / /*replacement text*/ /', -1, Var1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Best,&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2020 12:48:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627165#M185068</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-25T12:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627171#M185070</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/313767"&gt;@Nira&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Can anybody help to solve ? Since TRANWRD function limits to only 200 characters. Thanks&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;RTM&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Length of Returned Variable&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;In a DATA step, if the TRANWRD function returns a value to a variable that has not previously been assigned a length, then that variable is given a length of 200bytes. You can use the &lt;STRONG&gt;LENGTH statement, before calling TRANWRD&lt;/STRONG&gt;, to change the length of the value.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2020 13:02:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627171#M185070</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2020-02-25T13:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627172#M185071</link>
      <description>Hi&lt;BR /&gt;Sorry I don’t understand Could you explain that?</description>
      <pubDate>Tue, 25 Feb 2020 13:05:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627172#M185071</guid>
      <dc:creator>Nira</dc:creator>
      <dc:date>2020-02-25T13:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627174#M185072</link>
      <description>Could you send me any sample using length</description>
      <pubDate>Tue, 25 Feb 2020 13:06:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627174#M185072</guid>
      <dc:creator>Nira</dc:creator>
      <dc:date>2020-02-25T13:06:52Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627181#M185073</link>
      <description>You are saying that if that variable length is not defined previously then it will take length as 200 bytes. So you said to use length function before tranwrd function. Did I understand your point correctly?</description>
      <pubDate>Tue, 25 Feb 2020 13:52:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627181#M185073</guid>
      <dc:creator>Nira</dc:creator>
      <dc:date>2020-02-25T13:52:53Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627186#M185074</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/313767"&gt;@Nira&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Could you send me any sample using length&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;See here: &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p1hgqgmxm3dpqcn1d4w5za5qbz0d.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;LENGTH Statement&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2020 14:24:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627186#M185074</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-02-25T14:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627187#M185075</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/313767"&gt;@Nira&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Can anybody help to solve ? Since TRANWRD function limits to only 200 characters. Thanks&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is not true (unless you are using SAS version 6). Why do you think that there is such a limit?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2020 14:30:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627187#M185075</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-02-25T14:30:28Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627386#M185200</link>
      <description>I code as you said&lt;BR /&gt;Var2 = PRXCHANGE(‘s/ $ DTEAPNTMT / Strip(APNTMT_DATE) /‘, 1, TXT);&lt;BR /&gt;&lt;BR /&gt;But got error as variables within regular expressions are not supported</description>
      <pubDate>Wed, 26 Feb 2020 03:02:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627386#M185200</guid>
      <dc:creator>Nira</dc:creator>
      <dc:date>2020-02-26T03:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627389#M185202</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;Did I understand your point correctly?&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Yes. That's what the manual says too.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 03:45:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627389#M185202</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-02-26T03:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627390#M185203</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; But got error as variables within regular expressions are not supported&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;You may not be ready to use Regular Expressions yet.&lt;/P&gt;
&lt;P&gt;This is *not* one of the first things a programmer learns, and you seem to be a novice programmer.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 03:48:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627390#M185203</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-02-26T03:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627407#M185207</link>
      <description>My input string length 500. In that String 3 variables need to be replaced. Since TRANWRD allows only 200 , from 201 positiong string is not displayed in the output.</description>
      <pubDate>Wed, 26 Feb 2020 06:05:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627407#M185207</guid>
      <dc:creator>Nira</dc:creator>
      <dc:date>2020-02-26T06:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627408#M185208</link>
      <description>Yes. I am new to SAS. But can understand the existing code by google.</description>
      <pubDate>Wed, 26 Feb 2020 06:06:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627408#M185208</guid>
      <dc:creator>Nira</dc:creator>
      <dc:date>2020-02-26T06:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627409#M185209</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/313767"&gt;@Nira&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TRANWRD() works for variables longer than 200 characters. It's just that if you use the tranwrd() function and assign the result to a new variable then this variable gets by default created with a length of 200 characters. That's why in below code variable want_string gets first created with a length statement so it can hold the full string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have(keep=have_string);
  infile datalines truncover;
  input str $100.;
  length have_string $500;
  retain have_string;
  have_string=catx(' ', have_string,str);
  if _n_=5 then output;
datalines;
Replace from one word to another word in a long string of more than 200 characters
You are saying that WORD if that variable length is not defined previously then it will take 
length as 200 bytes. So you said to use WORD length function before tranwrd function. 
Did I understand your point correctly?
But got error as variables within WORD regular expressions are not supported
;

data want;
  set have;
  length want_string $500;
  want_string=tranwrd(have_string,'WORD','OTHERWORD');
run;

proc print data=want;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 06:28:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627409#M185209</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-02-26T06:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627411#M185210</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/313767"&gt;@Nira&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;My input string length 500. In that String 3 variables need to be replaced. Since TRANWRD allows only 200 , from 201 positiong string is not displayed in the output.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;See my previous post. That should explain it to you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use syntax like: new_variable = tranwrd(....); and this is the first time that new_variable has been listed in your code then this new_variable gets created with a default length of 200 - which in your case is too short and the source string gets truncated.&lt;/P&gt;
&lt;P&gt;In such cases: Use a length statement at the beginning of your code -&amp;gt; length new_variable $500; Now you've got what you need and things will work.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 06:27:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627411#M185210</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-02-26T06:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627434#M185229</link>
      <description>Thanks for the clear explanation. Another problem why it truncated was due to SYMGET function. But not sure why it truncates. So i declare length function for that symget varible and Also for new variable as you said. After that i got correct outptut. But want to know the reason Why symget truncates the string</description>
      <pubDate>Wed, 26 Feb 2020 08:23:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627434#M185229</guid>
      <dc:creator>Nira</dc:creator>
      <dc:date>2020-02-26T08:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627436#M185231</link>
      <description>&lt;P&gt;From the documentation of the &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n08h8unph3lz0un1ap3kqru4iym0.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;SYMGET Function&lt;/A&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If the SYMGET function returns a value to a variable that has not yet been assigned a length, by default the variable is assigned a length of 200.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is a VERY BIG reason why Maxim 1 (Read the Documentation) is number one. It is the most important and most helpful rule for people working with SAS.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 08:33:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627436#M185231</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-02-26T08:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627437#M185232</link>
      <description />
      <pubDate>Wed, 26 Feb 2020 08:42:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627437#M185232</guid>
      <dc:creator>Nira</dc:creator>
      <dc:date>2020-02-26T08:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace a word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627439#M185234</link>
      <description>Thankyou.</description>
      <pubDate>Wed, 26 Feb 2020 08:43:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-a-word/m-p/627439#M185234</guid>
      <dc:creator>Nira</dc:creator>
      <dc:date>2020-02-26T08:43:47Z</dc:date>
    </item>
  </channel>
</rss>

