<?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: logic behind concatenating variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/logic-behind-concatenating-variables/m-p/183416#M46687</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried using the following code, however, it only shows FA. I'm preparing for the base certification exam, any advise? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data work.staff;&lt;/P&gt;&lt;P&gt;length &lt;SPAN style="font-size: 13.3333330154419px;"&gt;JobCategory &lt;/SPAN&gt;$ 20.;&lt;/P&gt;&lt;P&gt;JobCategory ='FA';&lt;/P&gt;&lt;P&gt;JobLevel ='1';&lt;/P&gt;&lt;P&gt;JobCategory = JobCategory || JobLevel;&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;However, the following code works instead of using || . I still do not understand why || is not working. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Catx(,&lt;SPAN style="font-size: 13.3333330154419px; line-height: 1.5em;"&gt;JobCategory,JobLevel);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;catt(JobCategory, JobLebel);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Jul 2015 02:58:48 GMT</pubDate>
    <dc:creator>sbasne</dc:creator>
    <dc:date>2015-07-07T02:58:48Z</dc:date>
    <item>
      <title>logic behind concatenating variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/logic-behind-concatenating-variables/m-p/183412#M46683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I'm preparing for SAS Base exam and I am having trouble understanding the logic behind the answer below.&lt;/P&gt;&lt;P&gt;Correct answer is A and I also confirmed this to be true by testing the below code in SAS.&lt;/P&gt;&lt;P&gt;However, I cannot think of a good reason why the variable is not concatenating.&lt;/P&gt;&lt;P&gt;I wondered if this has to do with the length of variable JobCategory, so I inserted a line &lt;STRONG&gt;&lt;EM&gt;Length JobCategory $100;&lt;/EM&gt;&lt;/STRONG&gt; in the 2nd line, but I still get 'FA' instead of answer choice C when I run the code in SAS.&lt;/P&gt;&lt;P&gt;Could anyone shed a light on this problem please? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Question&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The following SAS program is submitted:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data work.staff;&lt;/P&gt;&lt;P&gt;JobCategory ='FA';&lt;/P&gt;&lt;P&gt;JobLevel ='1';&lt;/P&gt;&lt;P&gt;JobCategory = JobCategory || JobLevel;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which one of the following is the following is the value of the variable JobCategory in the output dataset?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Answer Choices&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;A.FA&lt;/P&gt;&lt;P&gt;B.FA1&lt;/P&gt;&lt;P&gt;C.FA 1&lt;/P&gt;&lt;P&gt;D.''(missing character value)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Feb 2014 19:26:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/logic-behind-concatenating-variables/m-p/183412#M46683</guid>
      <dc:creator>hatsumi</dc:creator>
      <dc:date>2014-02-22T19:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: logic behind concatenating variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/logic-behind-concatenating-variables/m-p/183413#M46684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data work.staff;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;length JobCategory $20;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;JobCategory ='FA';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;JobLevel ='1';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;JobCategory = JobCategory || JobLevel;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;put JobCategory;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;JobCategory = trim(JobCategory) || JobLevel;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;put JobCategory;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rules:&lt;/P&gt;&lt;P&gt;SAS variables get their length from their first use/mention. Without the length statement, JobCategory gets length = 2. &lt;/P&gt;&lt;P&gt;SAS character variables have a fixed length. With &lt;STRONG&gt;length JobCategory $20&lt;/STRONG&gt; the value after assignment is "FA__________________". &lt;/P&gt;&lt;P&gt;The concatenate operation generates a string of length 21 which gets chopped back to length 20 when assigned to string JobCategory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hth.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Feb 2014 19:49:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/logic-behind-concatenating-variables/m-p/183413#M46684</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-02-22T19:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: logic behind concatenating variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/logic-behind-concatenating-variables/m-p/183414#M46685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much for your prompt response and clear explanation!&lt;/P&gt;&lt;P&gt;I didn't think about trailing blanks in JobCategory variable, but now I understand why '1' got chopped off.&lt;/P&gt;&lt;P&gt;I also tried running your code, but it worked without put statement too.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Feb 2014 20:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/logic-behind-concatenating-variables/m-p/183414#M46685</guid>
      <dc:creator>hatsumi</dc:creator>
      <dc:date>2014-02-22T20:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: logic behind concatenating variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/logic-behind-concatenating-variables/m-p/183415#M46686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Understanding the concatenation operator || is important for interpreting older SAS code. But for contemporary code, it has been mostly replaced with functions &lt;STRONG&gt;catx&lt;/STRONG&gt;, &lt;STRONG&gt;cats&lt;/STRONG&gt; and &lt;STRONG&gt;catt &lt;/STRONG&gt;which provide better functionality. Make sure you understand those as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Feb 2014 20:33:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/logic-behind-concatenating-variables/m-p/183415#M46686</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-02-22T20:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: logic behind concatenating variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/logic-behind-concatenating-variables/m-p/183416#M46687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried using the following code, however, it only shows FA. I'm preparing for the base certification exam, any advise? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data work.staff;&lt;/P&gt;&lt;P&gt;length &lt;SPAN style="font-size: 13.3333330154419px;"&gt;JobCategory &lt;/SPAN&gt;$ 20.;&lt;/P&gt;&lt;P&gt;JobCategory ='FA';&lt;/P&gt;&lt;P&gt;JobLevel ='1';&lt;/P&gt;&lt;P&gt;JobCategory = JobCategory || JobLevel;&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;However, the following code works instead of using || . I still do not understand why || is not working. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Catx(,&lt;SPAN style="font-size: 13.3333330154419px; line-height: 1.5em;"&gt;JobCategory,JobLevel);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;catt(JobCategory, JobLebel);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 02:58:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/logic-behind-concatenating-variables/m-p/183416#M46687</guid>
      <dc:creator>sbasne</dc:creator>
      <dc:date>2015-07-07T02:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: logic behind concatenating variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/logic-behind-concatenating-variables/m-p/183417#M46688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please read the answer marked 'correct' carefully, run the code, try to understand the outcome.&amp;nbsp; For catx, catt, you need to read the manual on how they process the variable content (especially on how they treat the trailing blanks) during the concatenation. Answers are all there for a prepared pair of eyes. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 14:32:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/logic-behind-concatenating-variables/m-p/183417#M46688</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-07-07T14:32:57Z</dc:date>
    </item>
  </channel>
</rss>

