<?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: Replace characters with a substring from a different variable. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replace-characters-with-a-substring-from-a-different-variable/m-p/395489#M95402</link>
    <description>&lt;P&gt;like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input VAR1$ DETAILS$20.;
datalines;
MAIN OHIO.!STREET
MAIN OHIO.!STREET
EAST TEXAS.!STREET
RUNN GEORGIA.!STREET
HOPP TEXAS.!STREET
;

data want(keep=name);
	set have;
	name = tranwrd(DETAILS, scan(DETAILS,-1,'.'), VAR1);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 13 Sep 2017 12:21:54 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2017-09-13T12:21:54Z</dc:date>
    <item>
      <title>Replace characters with a substring from a different variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-characters-with-a-substring-from-a-different-variable/m-p/395484#M95399</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;I have been trying to use TRANWORD with a subsring, for example&lt;BR /&gt;&amp;nbsp;name=TRANWRD(details,'!STREET',SUBSTR(var1,1,4);&amp;nbsp;&lt;BR /&gt;&amp;nbsp;Not sure there is a way to do this with TRANWORD or TRANSLATE. Or what is the best approach. Thx for the help in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;**&lt;STRONG&gt; DATA HAVE **&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;U&gt;VAR1&lt;/U&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;U&gt;DETAILS&lt;/U&gt;&lt;BR /&gt;&amp;nbsp;MAIN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OHIO.!STREET&lt;BR /&gt;&amp;nbsp;MAIN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OHIO.!STREET&lt;BR /&gt;&amp;nbsp;EAST&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TEXAS.!STREET&lt;BR /&gt;&amp;nbsp;RUNN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GEORGIA.!STREET&lt;BR /&gt;&amp;nbsp;HOPP &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TEXAS.!STREET&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;** DATA WANT **&lt;/STRONG&gt;&lt;BR /&gt;&amp;nbsp;OHIO.MAIN&lt;BR /&gt;&amp;nbsp;OHIO.MAIN&lt;BR /&gt;&amp;nbsp;TEXAS.EAST&lt;BR /&gt;&amp;nbsp;GEORGIA.RUNN&lt;BR /&gt;&amp;nbsp;TEXAS.HOPP&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 12:10:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-characters-with-a-substring-from-a-different-variable/m-p/395484#M95399</guid>
      <dc:creator>a079011</dc:creator>
      <dc:date>2017-09-13T12:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: Replace characters with a substring from a different variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-characters-with-a-substring-from-a-different-variable/m-p/395489#M95402</link>
      <description>&lt;P&gt;like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input VAR1$ DETAILS$20.;
datalines;
MAIN OHIO.!STREET
MAIN OHIO.!STREET
EAST TEXAS.!STREET
RUNN GEORGIA.!STREET
HOPP TEXAS.!STREET
;

data want(keep=name);
	set have;
	name = tranwrd(DETAILS, scan(DETAILS,-1,'.'), VAR1);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Sep 2017 12:21:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-characters-with-a-substring-from-a-different-variable/m-p/395489#M95402</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-09-13T12:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: Replace characters with a substring from a different variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-characters-with-a-substring-from-a-different-variable/m-p/395490#M95403</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input VAR1 $ DETAILS $ 20. ;
cards;
 MAIN OHIO.!STREET
 MAIN OHIO.!STREET
 EAST TEXAS.!STREET
 RUNN GEORGIA.!STREET
 HOPP TEXAS.!STREET
 ;
run;

data want;
	set have;
        var =catx('.',scan(details,1,'.!'),VAR1);
	keep var;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Sep 2017 12:24:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-characters-with-a-substring-from-a-different-variable/m-p/395490#M95403</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2017-09-13T12:24:18Z</dc:date>
    </item>
    <item>
      <title>Re: Replace characters with a substring from a different variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-characters-with-a-substring-from-a-different-variable/m-p/395502#M95409</link>
      <description>&lt;P&gt;Just realized I forgot to add that !STREET won't always be after the first period.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;**&lt;STRONG&gt; DATA HAVE **&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;U&gt;VAR1&lt;/U&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;U&gt;DETAILS&lt;/U&gt;&lt;BR /&gt;&amp;nbsp;MAIN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OHIO.!STREET&lt;BR /&gt;&amp;nbsp;MAIN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;!STREET.OHIO&lt;BR /&gt;&amp;nbsp;EAST&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARK.TEXAS.!STREET&lt;BR /&gt;&amp;nbsp;RUNN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GEORGIA.!STREET.ATL&lt;BR /&gt;&amp;nbsp;HOPP &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TEXAS.HOUTON.!STREET.HOME&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;** DATA WANT **&lt;/STRONG&gt;&lt;BR /&gt;OHIO.MAIN&lt;BR /&gt;MAIN.OHIO&lt;BR /&gt;ARK.TEXAS.EAST&lt;BR /&gt;GEORGIA.RUNN.ATL&lt;/P&gt;
&lt;P&gt;TEXAS.HOUTON.HOPP.HOME&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 12:43:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-characters-with-a-substring-from-a-different-variable/m-p/395502#M95409</guid>
      <dc:creator>a079011</dc:creator>
      <dc:date>2017-09-13T12:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Replace characters with a substring from a different variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-characters-with-a-substring-from-a-different-variable/m-p/395513#M95412</link>
      <description>&lt;P&gt;But the string to be replaced is always exactly&amp;nbsp;"!STREET"? In that case&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input VAR1$ DETAILS$50.;
datalines;
MAIN OHIO.!STREET
MAIN !STREET.OHIO
EAST ARK.TEXAS.!STREET
RUNN GEORGIA.!STREET.ATL
HOPP TEXAS.HOUTON.!STREET.HOME
;

data want(keep=name);
	set have;
	name = compress(tranwrd(DETAILS, "!STREET", VAR1));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Sep 2017 12:53:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-characters-with-a-substring-from-a-different-variable/m-p/395513#M95412</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-09-13T12:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: Replace characters with a substring from a different variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-characters-with-a-substring-from-a-different-variable/m-p/395514#M95413</link>
      <description>&lt;P&gt;This does work. name=TRANWRD(details,'!STREET',SUBSTR(var1,1,4)); I was forgetting the last ).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thx for all the help!!!!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 12:56:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-characters-with-a-substring-from-a-different-variable/m-p/395514#M95413</guid>
      <dc:creator>a079011</dc:creator>
      <dc:date>2017-09-13T12:56:02Z</dc:date>
    </item>
  </channel>
</rss>

