<?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: TRANWRD in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871236#M82653</link>
    <description>&lt;P&gt;Thanks for your time and effort!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The version below of what you put together seems to work. The only issue now is that it gives me just one observation. How can I modify it so that it gives me all 500+?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data sloeconvert7 ;&lt;BR /&gt;SLOE_1_Reg ="Midwest (IA, IL, IN, OH, KS, MI, MN, MO, ND, SD, WI)" ;&lt;BR /&gt;Region="Midwest" ;&lt;BR /&gt;Region=tranwrd(SLOE_1_Reg,"Midwest (IA, IL, IN, OH, KS, MI, MN, MO, ND, SD, WI)","Midwest");&lt;BR /&gt;PUT SLOE_1_Reg= ;&lt;BR /&gt;PUT Region= ;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Apr 2023 18:43:20 GMT</pubDate>
    <dc:creator>newtriks</dc:creator>
    <dc:date>2023-04-21T18:43:20Z</dc:date>
    <item>
      <title>How to use TRANWRD function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871197#M82644</link>
      <description>&lt;P&gt;I'm trying to remove bothersome and unnecessary characters from my dataset. A portion of my code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA regions;&lt;BR /&gt;SET regionsc;&lt;BR /&gt;SLOE_1_Reg = TRANWRD (SLOE_1_Reg,'Midwest (IA, IL, IN, OH, KS, MI, MN, MO, ND, SD, WI)','Midwest');&lt;/P&gt;
&lt;P&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...This returns the identical column with which I started. There's no error message in the log. What am I doing wrong?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks-&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2023 13:22:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871197#M82644</guid>
      <dc:creator>newtriks</dc:creator>
      <dc:date>2023-04-27T13:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871203#M82645</link>
      <description>&lt;P&gt;We need for you to provide a portion of your data in order to figure this out. Please provide the data as working SAS data step code, which you can type in yourself, or follow &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;these instructions&lt;/A&gt;. Please do not provide data as Excel files or as screen captures or any other format.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 17:13:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871203#M82645</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-04-21T17:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871207#M82646</link>
      <description>&lt;P&gt;A simple example, assuming you want to remove all the states using &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0pgemqcslm9uen1tvr5gcrusgrw.htm" target="_self"&gt;TRANWRD&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I'm assuming you have the value I set in haveStr, and want to convert it to the value I have in wantStr.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I suggest you provide a sample of the data you are attempting to transform, what you want as a result, what code you currently have and the log from that code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1456  data _null_ ;
1457      haveStr="Midwest (IA, IL, IN, OH, KS, MI, MN, MO, ND, SD, WI)" ;
1458      wantStr="Midwest" ;
1459
1460      convert=tranwrd(haveStr,"Midwest (IA, IL, IN, OH, KS, MI, MN, MO, ND, SD,
1460! WI)","MidWest") ;
1461
1462      put haveStr= ;
1463      put wantStr= ;
1464      put convert= ;
1465  run ;

haveStr=Midwest (IA, IL, IN, OH, KS, MI, MN, MO, ND, SD, WI)
wantStr=Midwest
convert=MidWest
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&lt;STRONG&gt;Admin Note:&lt;/STRONG&gt;&lt;BR /&gt;Marking this as the Accepted Solution, as it has a link to the TRANWRD documentation&lt;BR /&gt;Also, want to call out replies by:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;which notes the importance of knowing your data:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;SPAN&gt;The spaces and commas are critical if you are going to make TRANWRD work&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;which offers a method to convert values that are "messy" inconsistent:&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;SLOE_1_Reg = prxchange('s/(\w+)\s*\(.+?\)/$1/',-1,SLOE_1_Reg);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Basically, this would replace substrings of the form "&lt;EM&gt;word&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(&lt;EM&gt;unwanted details&lt;/EM&gt;)" with "&lt;EM&gt;word&lt;/EM&gt;".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2023 13:19:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871207#M82646</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2023-04-27T13:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871210#M82647</link>
      <description>&lt;P&gt;Please provide some sample data so that I can figure out the solutions and the cause.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Vijay&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 17:33:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871210#M82647</guid>
      <dc:creator>vijaypratap0195</dc:creator>
      <dc:date>2023-04-21T17:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871220#M82651</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/413680"&gt;@newtriks&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If TRANWRD does not replace the substring specified in the second argument, the corresponding substring in variable &lt;FONT face="courier new,courier"&gt;SLOE_1_Reg&lt;/FONT&gt; must be different. Possible differences include missing blanks, double blanks, other white-space characters (such as 'A0'x or tab characters) instead of blanks, upper/lower case, etc. So, either you need to ensure that the search string matches &lt;EM&gt;exactly&lt;/EM&gt; what you want to replace (use the $HEX. format to determine the exact content of variable&amp;nbsp;&lt;FONT face="courier new,courier"&gt;SLOE_1_Reg&lt;/FONT&gt;) or use more flexible pattern matching, e.g. with &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n0r8h2fa8djqf1n1cnenrvm573br.htm" target="_blank" rel="noopener"&gt;PRXCHANGE&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SLOE_1_Reg = prxchange('s/(\w+)\s*\(.+?\)/$1/',-1,SLOE_1_Reg);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Basically, this would replace substrings of the form "&lt;EM&gt;word&lt;/EM&gt; (&lt;EM&gt;unwanted details&lt;/EM&gt;)" with "&lt;EM&gt;word&lt;/EM&gt;".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;Edit: Corrected typo: The intention was to include the case of &lt;EM&gt;no&lt;/EM&gt; space between "&lt;EM&gt;word&lt;/EM&gt;" and the opening parenthesis by using &lt;FONT face="courier new,courier"&gt;\s*&lt;/FONT&gt;, not &lt;FONT face="courier new,courier"&gt;\s+&lt;/FONT&gt;, in the regex.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 21:33:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871220#M82651</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-04-21T21:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871236#M82653</link>
      <description>&lt;P&gt;Thanks for your time and effort!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The version below of what you put together seems to work. The only issue now is that it gives me just one observation. How can I modify it so that it gives me all 500+?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data sloeconvert7 ;&lt;BR /&gt;SLOE_1_Reg ="Midwest (IA, IL, IN, OH, KS, MI, MN, MO, ND, SD, WI)" ;&lt;BR /&gt;Region="Midwest" ;&lt;BR /&gt;Region=tranwrd(SLOE_1_Reg,"Midwest (IA, IL, IN, OH, KS, MI, MN, MO, ND, SD, WI)","Midwest");&lt;BR /&gt;PUT SLOE_1_Reg= ;&lt;BR /&gt;PUT Region= ;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 18:43:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871236#M82653</guid>
      <dc:creator>newtriks</dc:creator>
      <dc:date>2023-04-21T18:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871260#M82654</link>
      <description>&lt;P&gt;Ok, this is an imported Excel file but I've put a few datalines together to give you an idea:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATALINES;&lt;/P&gt;&lt;P&gt;gender Med_Type SLOE_1_Reg&amp;nbsp;&lt;/P&gt;&lt;P&gt;M Private Midwest(IA, IL, IN, OH, KS, MI, MN, MO, ND, SD, WI)&lt;/P&gt;&lt;P&gt;F Public Northeast(CT, District of Columbia, DE, MA, MD, ME, NH, PA, NY, NJ, RI, VT)&lt;/P&gt;&lt;P&gt;F Private Southeast(AL, AR, FL, CA, KY, LA, PR, MS, NC, SC, TN, VA, WV)&lt;/P&gt;&lt;P&gt;M Public West(AK, AZ, CA, CO, ID, HI, MT, NM, NV, OK, OR, TX, UT, WA, WY)&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are correct, I'm just trying to get those overly-descriptive cells down to the basic single word which describes the region.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all for your time and efforts!&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV align="center"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV align="center"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 19:59:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871260#M82654</guid>
      <dc:creator>newtriks</dc:creator>
      <dc:date>2023-04-21T19:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871268#M82655</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/413680"&gt;@newtriks&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Ok, this is an imported Excel file but I've put a few datalines together to give you an idea:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATALINES;&lt;/P&gt;
&lt;P&gt;gender Med_Type SLOE_1_Reg&amp;nbsp;&lt;/P&gt;
&lt;P&gt;M Private Midwest(IA, IL, IN, OH, KS, MI, MN, MO, ND, SD, WI)&lt;/P&gt;
&lt;P&gt;F Public Northeast(CT, District of Columbia, DE, MA, MD, ME, NH, PA, NY, NJ, RI, VT)&lt;/P&gt;
&lt;P&gt;F Private Southeast(AL, AR, FL, CA, KY, LA, PR, MS, NC, SC, TN, VA, WV)&lt;/P&gt;
&lt;P&gt;M Public West(AK, AZ, CA, CO, ID, HI, MT, NM, NV, OK, OR, TX, UT, WA, WY)&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are correct, I'm just trying to get those overly-descriptive cells down to the basic single word which describes the region.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you all for your time and efforts&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Those examples look like what you really want is the first word, which the SCAN function will get quite easily.&lt;/P&gt;
&lt;PRE&gt;length region $ 10;
region = scan(SLOE_1_Reg ,1,'(');&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Apr 2023 21:19:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871268#M82655</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-04-21T21:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871270#M82656</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/413680"&gt;@newtriks&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Ok, this is an imported Excel file but I've put a few datalines together to give you an idea:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATALINES;&lt;/P&gt;
&lt;P&gt;gender Med_Type SLOE_1_Reg&amp;nbsp;&lt;/P&gt;
&lt;P&gt;M Private Midwest(IA, IL, IN, OH, KS, MI, MN, MO, ND, SD, WI)&lt;/P&gt;
&lt;P&gt;F Public Northeast(CT, District of Columbia, DE, MA, MD, ME, NH, PA, NY, NJ, RI, VT)&lt;/P&gt;
&lt;P&gt;F Private Southeast(AL, AR, FL, CA, KY, LA, PR, MS, NC, SC, TN, VA, WV)&lt;/P&gt;
&lt;P&gt;M Public West(AK, AZ, CA, CO, ID, HI, MT, NM, NV, OK, OR, TX, UT, WA, WY)&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are correct, I'm just trying to get those overly-descriptive cells down to the basic single word which describes the region.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you all for your time and efforts!&lt;/P&gt;
&lt;DIV class=""&gt;
&lt;DIV align="center"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class=""&gt;
&lt;DIV align="center"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You have typed different text on the Midwest line than what you showed in the original message. The spaces and commas are critical if you are going to make TRANWRD work, and so if we're going to help, you absolutely must provide data in the form I requested, as working SAS data step code, preferably using the instructions at the link I gave. That's absolutely MUST provide data in the form I requested. We are trying to help you, but you need to help us.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 21:56:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871270#M82656</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-04-21T21:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871857#M82659</link>
      <description>&lt;P&gt;Thank you all for your interest and help. I ultimately found it easier to fix the columns in Excel and then re-import and merge them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate your time.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 13:28:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-TRANWRD-function/m-p/871857#M82659</guid>
      <dc:creator>newtriks</dc:creator>
      <dc:date>2023-04-25T13:28:50Z</dc:date>
    </item>
  </channel>
</rss>

