<?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: problem while concatenation using || in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/problem-while-concatenation-using/m-p/296403#M62095</link>
    <description>&lt;P&gt;This is correct, because of trailing spaces.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the first example it creates jobcategory with a length of 2 and then there's no room for the remaining text.&lt;/P&gt;
&lt;P&gt;In the second example it creates jobcategory with a length of 15 - 2 chars and trailing spaces.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would assign a length at the beginning and use a CATT() function instead as it deals with the&amp;nbsp;trailing spaces and I don't have to think about them.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data staff;
length jobcategory $15.;
jobcategory = 'FA';
joblevel = '1';
jobcategory = catt(jobcategory, joblevel);
run;

proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 04 Sep 2016 18:23:47 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-09-04T18:23:47Z</dc:date>
    <item>
      <title>problem while concatenation using ||</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-while-concatenation-using/m-p/296402#M62094</link>
      <description>&lt;P&gt;Please see the below SAS code and provide&amp;nbsp;a explanation on why the value of variable jobcategory is &lt;STRONG&gt;"FA"&lt;/STRONG&gt; only&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data staff;
jobcategory = 'FA';
joblevel = '1';
jobcategory = jobcategory||joblevel;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am including a Length statement after data statement as &lt;STRONG&gt;"Length jobcategory $20.", &lt;/STRONG&gt;still answer is same&lt;STRONG&gt; "FA".&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but we are getting correct value once the output variable is changed to&lt;STRONG&gt; "JOBCATEGORY1" &lt;/STRONG&gt;as shown below&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data staff;
length jobcategory1 $15.;
jobcategory = 'FA';
joblevel = '1';
jobcategory1 = jobcategory||joblevel;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Thanks in advance&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Sep 2016 18:14:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-while-concatenation-using/m-p/296402#M62094</guid>
      <dc:creator>monusing</dc:creator>
      <dc:date>2016-09-04T18:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: problem while concatenation using ||</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-while-concatenation-using/m-p/296403#M62095</link>
      <description>&lt;P&gt;This is correct, because of trailing spaces.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the first example it creates jobcategory with a length of 2 and then there's no room for the remaining text.&lt;/P&gt;
&lt;P&gt;In the second example it creates jobcategory with a length of 15 - 2 chars and trailing spaces.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would assign a length at the beginning and use a CATT() function instead as it deals with the&amp;nbsp;trailing spaces and I don't have to think about them.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data staff;
length jobcategory $15.;
jobcategory = 'FA';
joblevel = '1';
jobcategory = catt(jobcategory, joblevel);
run;

proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 04 Sep 2016 18:23:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-while-concatenation-using/m-p/296403#M62095</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-04T18:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: problem while concatenation using ||</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-while-concatenation-using/m-p/296404#M62096</link>
      <description>&lt;P&gt;When first occurence of a variable is assignment of a string, like:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &lt;STRONG&gt;data out;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var = 'STRING';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;....&lt;/P&gt;&lt;P&gt;then the length of that variable is the length of the string (in this example 6 chracters);&lt;/P&gt;&lt;P&gt;when you try to assign a longer string it is truncated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To solve it you need define a length - the maximum expected for that variable;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; data out;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;length var $10;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var = 'STRING'; &amp;nbsp;output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var = 'Longer one'; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var = 'Too mutch long string'; &amp;nbsp;output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; check out and you will see that the 3rd line is truncated to 10 characters only;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Sep 2016 18:24:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-while-concatenation-using/m-p/296404#M62096</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-09-04T18:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: problem while concatenation using ||</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-while-concatenation-using/m-p/296407#M62098</link>
      <description>&lt;P&gt;&amp;nbsp;you want to say that when i assign the length as 15 initially, it includes &amp;nbsp;traling spaces also?.&lt;/P&gt;&lt;P&gt;So &amp;nbsp;length is a compiling time statement?&lt;/P&gt;</description>
      <pubDate>Sun, 04 Sep 2016 18:48:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-while-concatenation-using/m-p/296407#M62098</guid>
      <dc:creator>monusing</dc:creator>
      <dc:date>2016-09-04T18:48:49Z</dc:date>
    </item>
  </channel>
</rss>

