<?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: How to modify variable length which has already been set? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-variable-length-which-has-already-been-set/m-p/249828#M47046</link>
    <description>&lt;P&gt;Good. But you still have to be sure that the total number n of trimmed trailing blanks is at least 3 for each observation, so that the length 15-n of the concatenated string is &amp;lt;=12. Leading blanks would be preserved.&lt;/P&gt;</description>
    <pubDate>Fri, 12 Feb 2016 21:54:17 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2016-02-12T21:54:17Z</dc:date>
    <item>
      <title>How to modify variable length which has already been set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-variable-length-which-has-already-been-set/m-p/249796#M47031</link>
      <description>&lt;P&gt;I am creating a new variable combining three different variables (all are CHARACTER) with the function below within a DATA Step. The result is a CHARACTER variable with $15.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;infile "/v_share/ali/sas_dataset/Calculations_Occupancy" linesize = 300 firstobs = 2 &amp;nbsp;DSD ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;Informat &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;variable 1 &amp;nbsp; &amp;nbsp;$3.0&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;variable 2 &amp;nbsp; &amp;nbsp; 8.0&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;input&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;variable 1 &amp;nbsp; &amp;nbsp;$&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;variable 2 &amp;nbsp; &amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;.&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;New_Variable&amp;nbsp;= variable1&amp;nbsp;!! &lt;SPAN&gt;variable 2&lt;/SPAN&gt;&amp;nbsp;!! &lt;SPAN&gt;variable 3&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;run;&lt;/FONT&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I change/modify the New_Variable legth to be $12 in my output?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2016 19:18:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-variable-length-which-has-already-been-set/m-p/249796#M47031</guid>
      <dc:creator>almmotamedi</dc:creator>
      <dc:date>2016-02-12T19:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify variable length which has already been set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-variable-length-which-has-already-been-set/m-p/249800#M47032</link>
      <description>Issue a length statement prior to the assignment.</description>
      <pubDate>Fri, 12 Feb 2016 19:24:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-variable-length-which-has-already-been-set/m-p/249800#M47032</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-02-12T19:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify variable length which has already been set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-variable-length-which-has-already-been-set/m-p/249820#M47041</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/65070"&gt;@almmotamedi﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I take it that your code example is only similar to what your real code looks like (blanks in variable names, ...). But I would still be&amp;nbsp;concerned about possible truncation issues. You wrote that all three variables are character variables (the numeric informat 8.0 suggests something else, though). If the default length of New_Variable is 15, this&amp;nbsp;must be&amp;nbsp;the sum of the lengths of the three character variables. (A numeric variable would contribute a length of 12 from the BEST12. format it would be converted with.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The concatenation with the "!!" operator does not trim trailing (or leading) blanks. So, if (for example) 3 and 8 were the lengths of character variables 1 and 2 (hence 15-(3+8)=4 was the length of variable 3), specifying &lt;FONT face="courier new,courier"&gt;length New_Variable $12;&lt;/FONT&gt; would leave only 1 character for variable 3, irrespective of the contents of the first two variables. Hence, the last three characters of variable 3 would always be truncated.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2016 21:09:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-variable-length-which-has-already-been-set/m-p/249820#M47041</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-12T21:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify variable length which has already been set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-variable-length-which-has-already-been-set/m-p/249826#M47045</link>
      <description>Its in fact :&lt;BR /&gt;&lt;BR /&gt;New_Variable = trim(variable 1) !! trim(variable 2) !! trim(variable 3)</description>
      <pubDate>Fri, 12 Feb 2016 21:45:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-variable-length-which-has-already-been-set/m-p/249826#M47045</guid>
      <dc:creator>almmotamedi</dc:creator>
      <dc:date>2016-02-12T21:45:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify variable length which has already been set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-variable-length-which-has-already-been-set/m-p/249828#M47046</link>
      <description>&lt;P&gt;Good. But you still have to be sure that the total number n of trimmed trailing blanks is at least 3 for each observation, so that the length 15-n of the concatenated string is &amp;lt;=12. Leading blanks would be preserved.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2016 21:54:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-variable-length-which-has-already-been-set/m-p/249828#M47046</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-12T21:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify variable length which has already been set?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-variable-length-which-has-already-been-set/m-p/250398#M47213</link>
      <description>&lt;P&gt;Thank you, in fact this is what had happended:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Removing one extra character (') from each variable, and then using concatenation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;C_ST =compress(C_ST,"'");&lt;BR /&gt;C_DSTRB_AREA =compress(C_DSTRB_AREA,"'");&lt;BR /&gt;N_RSK =compress(N_RSK,"'"); &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;New_Variable&amp;nbsp;= trim(C_ST) !! trim(C_DSTRB_AREA) !! trim(N_RSK) ;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2016 17:36:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-variable-length-which-has-already-been-set/m-p/250398#M47213</guid>
      <dc:creator>almmotamedi</dc:creator>
      <dc:date>2016-02-16T17:36:15Z</dc:date>
    </item>
  </channel>
</rss>

