<?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 Function and Variable Length. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/TRANWRD-Function-and-Variable-Length/m-p/83834#M24059</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In general it is a BAD idea to attach a FORMAT to a character variable for just the reason you state.&amp;nbsp; If you have a variable with length of 8 and it has a format of $5 attached to it then when you try to display the value it is truncated.&lt;/P&gt;&lt;P&gt;Unfortunately SAS has a nasty habit of always attaching formats to character variables when you pull the data from an external database system such as Oracle.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I find the easiest thing to due is to use a FORMAT statement in a data step to remove the formats.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format _character_ ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Aug 2012 18:12:45 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2012-08-03T18:12:45Z</dc:date>
    <item>
      <title>TRANWRD Function and Variable Length.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/TRANWRD-Function-and-Variable-Length/m-p/83829#M24054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif; color: black; background-color: white; background-position: initial initial; background-repeat: initial initial;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif; color: black; background-color: white; background-position: initial initial; background-repeat: initial initial;"&gt;Hi all—&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif; color: black; background-color: white; background-position: initial initial; background-repeat: initial initial;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;&lt;SPAN style="font-size: 10pt; color: black; background-color: white; background-position: initial initial; background-repeat: initial initial;"&gt;I’m having trouble with the &lt;SPAN style="font-size: 10pt; color: black; background-color: white; background-position: initial initial; background-repeat: initial initial;"&gt;TRANWRD function and variable length.&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp; I have a large data set that I continually append data to. In the data set the variable &lt;STRONG style="color: #000000; background-color: #ffffff;"&gt;AGENCY&lt;/STRONG&gt; has a length of 5. I need to fix the value of ‘ST JO’ contained in the &lt;/SPAN&gt;&lt;STRONG style=": ; color: #000000; background-color: #ffffff; font-family: 'Courier New';"&gt;AGENCY &lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; font-family: 'Courier New';"&gt;variable&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 10pt;"&gt;&amp;nbsp; and swap it out for ‘ST JOHN'. When I add in the LENGTH statement for &lt;/SPAN&gt;&lt;STRONG style="color: #000000; background-color: #ffffff; font-family: Arial;"&gt;AGENCY&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 10pt;"&gt;the variable length does change but the value stays as 'ST JO' and does not change/correct to 'ST JOHN'. &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; want &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; AGENCY $&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;8&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; have &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;AGENCY =TRANWRD(AGENCY,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'ST JO'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'ST JOHN'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;Thoughts?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;Thanks! &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 16:46:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/TRANWRD-Function-and-Variable-Length/m-p/83829#M24054</guid>
      <dc:creator>Mgarret</dc:creator>
      <dc:date>2012-08-03T16:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD Function and Variable Length.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/TRANWRD-Function-and-Variable-Length/m-p/83830#M24055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Works fine for me.&amp;nbsp; Are you sure that is what is in your data?&amp;nbsp; Perhaps the space is not really a space?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input agency $5.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;ST JO&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length AGENCY $8;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; AGENCY =TRANWRD(AGENCY,'ST JO','ST JOHN') ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put agency=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 16:51:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/TRANWRD-Function-and-Variable-Length/m-p/83830#M24055</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-08-03T16:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD Function and Variable Length.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/TRANWRD-Function-and-Variable-Length/m-p/83831#M24056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom--&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is this last step do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;put agency=;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Thanks! &lt;/SPAN&gt;&lt;STRONG style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 17:00:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/TRANWRD-Function-and-Variable-Length/m-p/83831#M24056</guid>
      <dc:creator>Mgarret</dc:creator>
      <dc:date>2012-08-03T17:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD Function and Variable Length.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/TRANWRD-Function-and-Variable-Length/m-p/83832#M24057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;put agency=;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;write the value of &lt;SPAN style="color: #ff0000;"&gt;agency&lt;/SPAN&gt; to log file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 17:08:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/TRANWRD-Function-and-Variable-Length/m-p/83832#M24057</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-08-03T17:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD Function and Variable Length.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/TRANWRD-Function-and-Variable-Length/m-p/83833#M24058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom and Linlin--&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue still seems to happen.&amp;nbsp; But it happens when I combine the data. I use a simple union ststment to do it:&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql; &lt;/P&gt;&lt;P&gt;create table want as&lt;/P&gt;&lt;P&gt;select * &lt;/P&gt;&lt;P&gt;from have &lt;/P&gt;&lt;P&gt;union &lt;/P&gt;&lt;P&gt;select * &lt;/P&gt;&lt;P&gt;from have; &lt;/P&gt;&lt;P&gt;quit; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like the variable lengths always stay the same But the Format and Informat values change. How do I keep them at the same value everytime? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 17:54:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/TRANWRD-Function-and-Variable-Length/m-p/83833#M24058</guid>
      <dc:creator>Mgarret</dc:creator>
      <dc:date>2012-08-03T17:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD Function and Variable Length.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/TRANWRD-Function-and-Variable-Length/m-p/83834#M24059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In general it is a BAD idea to attach a FORMAT to a character variable for just the reason you state.&amp;nbsp; If you have a variable with length of 8 and it has a format of $5 attached to it then when you try to display the value it is truncated.&lt;/P&gt;&lt;P&gt;Unfortunately SAS has a nasty habit of always attaching formats to character variables when you pull the data from an external database system such as Oracle.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I find the easiest thing to due is to use a FORMAT statement in a data step to remove the formats.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format _character_ ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 18:12:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/TRANWRD-Function-and-Variable-Length/m-p/83834#M24059</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-08-03T18:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD Function and Variable Length.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/TRANWRD-Function-and-Variable-Length/m-p/83835#M24060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom Thanks! last question, I just want to make sure I'm understanding you. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;does &lt;STRONG&gt;_character_&lt;/STRONG&gt; means it applies to all the character variables in the data set. What if I have numeric variables in the data set as well?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 18:20:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/TRANWRD-Function-and-Variable-Length/m-p/83835#M24060</guid>
      <dc:creator>Mgarret</dc:creator>
      <dc:date>2012-08-03T18:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD Function and Variable Length.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/TRANWRD-Function-and-Variable-Length/m-p/83836#M24061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Right.&amp;nbsp; There are many ways to specify lists of variables. _character_ , _numeric_ and _all_ are useful ones. You can also use ranges of variables with numeric suffix&amp;nbsp; (VAR1 - VAR20) or based on the order in the dataset ( ID -- ADDRESS). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Numeric variable formats are normally not as big a problem. In particular DATE, TIME and DATETIME formats are needed so that the values appear properly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The other tricky thing about the format statement is that it works to remove the formats because it does not specify a format after the variable list as you would normally do when using the format statement to attach formats.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 18:36:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/TRANWRD-Function-and-Variable-Length/m-p/83836#M24061</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-08-03T18:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD Function and Variable Length.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/TRANWRD-Function-and-Variable-Length/m-p/83837#M24062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ... removing formats is one of the tasks that you can also accomplish with PROC DATASETS rather than a data step&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if the data set is large, you might save some time with ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;proc datasets lib=&amp;lt;whatever&amp;gt; nolist;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;modify want;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;format _character_;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 19:27:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/TRANWRD-Function-and-Variable-Length/m-p/83837#M24062</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2012-08-03T19:27:50Z</dc:date>
    </item>
  </channel>
</rss>

