<?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: Addresses update tranwrd in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Addresses-update-tranwrd/m-p/828407#M35418</link>
    <description>&lt;P&gt;I don't understand the problem: "I have tried propcase(tranwrd(ADDR,'Cl','Close')) as ADDR. But this only does one name per time." - Please post the code you have used along with the log. So that we what happens actually.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For data cleaning i would always use a data step, the code is easier to debug. One problem could be caused by the length of the variable addr. Is it long enough to hold the additional chars?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A data step could look this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  length addr_expanded $ 100;
  addr_expanded = tranwrd(addr, 'Rd', 'Road');
  addr_expanded = tranwrd(addr_expanded, 'AVE', 'Avenue');
  addr_expanded = tranwrd(addr_expanded, 'CL', Close');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 12 Aug 2022 04:39:07 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2022-08-12T04:39:07Z</dc:date>
    <item>
      <title>Addresses update tranwrd</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Addresses-update-tranwrd/m-p/828389#M35414</link>
      <description>&lt;P&gt;Hi there&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My input data is below, I would like to change Rd to Road, AVE to Avenue, CL to close etc this is part of it I have lots of weird address as well.&lt;/P&gt;&lt;P&gt;I have tried&amp;nbsp;propcase(tranwrd(ADDR,'Cl','Close')) as ADDR. But this only does one name per time. Is there any chance I can update Rd, AVE and CL in one data step?&lt;/P&gt;&lt;P&gt;Input&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;Addr&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Amy&lt;/TD&gt;&lt;TD&gt;12 Stream Rd&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Mary&lt;/TD&gt;&lt;TD&gt;1/891 Mason AVE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;John&lt;/TD&gt;&lt;TD&gt;821 Stream Road&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Ivy&lt;/TD&gt;&lt;TD&gt;67 Tork CL&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Martin&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;5/891 Mason Avenue&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expectation output&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;Address&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Amy&lt;/TD&gt;&lt;TD&gt;12 Stream Road&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Mary&lt;/TD&gt;&lt;TD&gt;1/891 Mason Avenue&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;John&lt;/TD&gt;&lt;TD&gt;821 Stream Road&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Ivy&lt;/TD&gt;&lt;TD&gt;67 Tork Close&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Martin&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;5/891 Mason Avenue&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2022 23:27:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Addresses-update-tranwrd/m-p/828389#M35414</guid>
      <dc:creator>miss2223</dc:creator>
      <dc:date>2022-08-11T23:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: Addresses update tranwrd</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Addresses-update-tranwrd/m-p/828407#M35418</link>
      <description>&lt;P&gt;I don't understand the problem: "I have tried propcase(tranwrd(ADDR,'Cl','Close')) as ADDR. But this only does one name per time." - Please post the code you have used along with the log. So that we what happens actually.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For data cleaning i would always use a data step, the code is easier to debug. One problem could be caused by the length of the variable addr. Is it long enough to hold the additional chars?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A data step could look this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  length addr_expanded $ 100;
  addr_expanded = tranwrd(addr, 'Rd', 'Road');
  addr_expanded = tranwrd(addr_expanded, 'AVE', 'Avenue');
  addr_expanded = tranwrd(addr_expanded, 'CL', Close');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Aug 2022 04:39:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Addresses-update-tranwrd/m-p/828407#M35418</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-08-12T04:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Addresses update tranwrd</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Addresses-update-tranwrd/m-p/828438#M35424</link>
      <description>&lt;PRE&gt;You could write many TRANWRD() for this in a data step. Like : 

data want;
set have;
ADDR=&amp;nbsp;propcase(prxchange('s/\bCl\b/Close/,-1,ADDR'));
ADDR=&amp;nbsp;propcase(prxchange('s/\bRd\b/Road/,-1,ADDR'));
ADDR=&amp;nbsp;propcase(prxchange('s/\bAVE\b/Avenue/,-1,ADDR'));
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Aug 2022 11:50:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Addresses-update-tranwrd/m-p/828438#M35424</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-08-12T11:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: Addresses update tranwrd</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Addresses-update-tranwrd/m-p/828728#M35450</link>
      <description>&lt;P&gt;This code works&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
Retain Name Address;
length Address $ 100;
input Name $	_Addr $ 100.;
infile datalines dsd dlm=',' truncover;
Address=tranwrd(tranwrd(tranwrd(_Addr,'Rd', "Road"),'AVE', "Avenue"),'CL',"Close");
drop _Addr;
datalines;
Amy	,2 Stream Rd
Mary,1/891 Mason AVE
John,821 Stream Road
Ivy,67 Tork CL
Martin ,5/891 Mason Avenue
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output will be as you wanted&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sajid01_0-1660582876257.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/74445iF0D3DD3CC7023254/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sajid01_0-1660582876257.png" alt="Sajid01_0-1660582876257.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 17:01:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Addresses-update-tranwrd/m-p/828728#M35450</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-08-15T17:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: Addresses update tranwrd</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Addresses-update-tranwrd/m-p/828749#M35451</link>
      <description>&lt;P&gt;datalines;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;Amy ,2 Stream St&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;Mary,1/891 Mason Street&lt;/FONT&gt;&lt;BR /&gt;John,821 Stream Road&lt;BR /&gt;Ivy,67 Tork CL&lt;BR /&gt;Martin ,5/891 Mason Avenue&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have one row that is St and another is Street. Applying the code&amp;nbsp;tranwrd(_Addr,'St', "Street"). The result turn up to be Streetreet. Any chance of fixing that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Amy 2 Streetream Street&lt;BR /&gt;Mary 1/891 Mason &lt;FONT color="#FF0000"&gt;Streetreet&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 20:08:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Addresses-update-tranwrd/m-p/828749#M35451</guid>
      <dc:creator>miss2223</dc:creator>
      <dc:date>2022-08-15T20:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: Addresses update tranwrd</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Addresses-update-tranwrd/m-p/828751#M35452</link>
      <description>Sure&lt;BR /&gt;Replace ‘St’ with ‘ St ‘.&lt;BR /&gt;Effectively we are adding a leading and trailing space to make sure only St is selected.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 15 Aug 2022 20:32:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Addresses-update-tranwrd/m-p/828751#M35452</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-08-15T20:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: Addresses update tranwrd</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Addresses-update-tranwrd/m-p/828755#M35453</link>
      <description>&lt;P&gt;if you run the tranwrd twice you will get&amp;nbsp;&lt;SPAN&gt;Streetreet&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 21:01:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Addresses-update-tranwrd/m-p/828755#M35453</guid>
      <dc:creator>yaakov555</dc:creator>
      <dc:date>2022-08-15T21:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: Addresses update tranwrd</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Addresses-update-tranwrd/m-p/828766#M35457</link>
      <description>&lt;P&gt;I have update the code to account for the presence of St in the address.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
Retain Name Address;
length Address $ 100;
input Name $	_Addr $ 100.;
infile datalines dsd dlm=',' truncover;
Address=tranwrd(tranwrd(tranwrd(tranwrd(_Addr,'Rd', "Road"),'AVE', "Avenue"),'CL',"Close"),' St '," Street");
drop _Addr;
datalines;
Samy ,2 Stream St
Amy	,2 Stream Rd
Mary,1/891 Mason AVE
John,821 Stream Road
Ivy,67 Tork CL
Martin ,5/891 Mason Avenue
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output will be like as shown below. It is what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sajid01_0-1660602486151.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/74448i32A67B50A848DA21/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sajid01_0-1660602486151.png" alt="Sajid01_0-1660602486151.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 22:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Addresses-update-tranwrd/m-p/828766#M35457</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-08-15T22:28:42Z</dc:date>
    </item>
  </channel>
</rss>

