<?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: Length statement before merge statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/621228#M182604</link>
    <description>&lt;P&gt;So the question is about a&amp;nbsp;&lt;STRONG&gt;&lt;FONT size="3"&gt;FORMAT&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT size="3"&gt;&lt;FONT size="2"&gt;, not a&amp;nbsp;&lt;STRONG&gt;&lt;FONT size="3"&gt;LENGTH&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT size="2"&gt;&lt;EM&gt;.&lt;/EM&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;This once again illustrates the importance of posting exact, precise questions.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;Maxim 42 in action.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 30 Jan 2020 17:01:43 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-01-30T17:01:43Z</dc:date>
    <item>
      <title>Length statement before merge statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/613780#M179322</link>
      <description>&lt;DIV class="_3xX726aBn29LDbsDtzr_6E _1Ap4F5maDtT1E1YuCiaO0r D3IL3FD0RFy_mkKLPwL4"&gt;&lt;DIV class="_292iotee39Lmt0MkQZ2hPV RichTextJSON-root"&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;Hi everyone! Can someone help me with this question? I took a practice SAS exam a couple days ago and there was this question that is absolutely driving me insane. The question was about using a length statement before the merge statement. I have always thought that if you add the length statement before the merge then the length statement chooses the length of the column. However, I got the answer wrong because apparently SAS uses the first table in the merge statement to choose the length and not the length statement even though it was written before. I feel like I am missing something here. Can someone help?&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="_1hwEKkB_38tIoal6fcdrt9"&gt;&lt;DIV class="_3-miAEojrCvx_4FQ8x3P-s"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 24 Dec 2019 20:19:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/613780#M179322</guid>
      <dc:creator>AdrianXavier</dc:creator>
      <dc:date>2019-12-24T20:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement before merge statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/613786#M179323</link>
      <description>&lt;P&gt;Maxim 4: Try It.&lt;/P&gt;
&lt;P&gt;This is the best way to put your mind at ease.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2019 21:14:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/613786#M179323</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-24T21:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement before merge statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/613795#M179324</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Maxim 4: Try It.&lt;/P&gt;
&lt;P&gt;This is the best way to put your mind at ease.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For clarity&amp;nbsp; of result you likely would want to make sure that the length statement in the code uses a different length than in either of the data set and the common variable should have different defined lengths as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And try a length in the statement 1) longer than in either set 2) shorter than in either set and possibly even 3) in between the lengths in the data sets.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2019 22:13:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/613795#M179324</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-12-24T22:13:20Z</dc:date>
    </item>
    <item>
      <title>Length statement before merge statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/613817#M179325</link>
      <description>&lt;DIV class="_3xX726aBn29LDbsDtzr_6E _1Ap4F5maDtT1E1YuCiaO0r D3IL3FD0RFy_mkKLPwL4"&gt;&lt;DIV class="_292iotee39Lmt0MkQZ2hPV RichTextJSON-root"&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;Hi everyone! Can someone help me with this question? I took a practice SAS exam a couple days ago and there was this question that is absolutely driving me insane. The question was about using a length statement before the merge statement. I have always thought that if you add the length statement before the merge then the length statement chooses the length of the column. However, I got the answer wrong because apparently SAS uses the first table in the merge statement to choose the length and not the length statement even though it was written before. I feel like I am missing something here. Can someone help?&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="_1hwEKkB_38tIoal6fcdrt9"&gt;&lt;DIV class="_3-miAEojrCvx_4FQ8x3P-s"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 25 Dec 2019 12:18:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/613817#M179325</guid>
      <dc:creator>MasonLogan</dc:creator>
      <dc:date>2019-12-25T12:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement before merge statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/613818#M179326</link>
      <description>&lt;P&gt;&lt;STRONG&gt;DUPLICATE THREAD&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;DO NOT REPLY HERE&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Reply at &lt;A href="https://communities.sas.com/t5/SAS-Studio/Length-statement-before-merge-statement/td-p/613780" target="_blank"&gt;https://communities.sas.com/t5/SAS-Studio/Length-statement-before-merge-statement/td-p/613780&lt;/A&gt; (where, by the way, a good answer has been provided)&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Dec 2019 12:20:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/613818#M179326</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-12-25T12:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement before merge statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/613820#M179327</link>
      <description>&lt;P&gt;Threads with identical questions merged.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Dec 2019 12:31:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/613820#M179327</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-25T12:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement before merge statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/613826#M179329</link>
      <description>&lt;P&gt;SAS will define the variable when it first needs to. So you are right that the LENGTH statement will set the type and length of the variable. The question is either wrong or you misunderstood what point they were trying to make.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Dec 2019 14:22:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/613826#M179329</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-25T14:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement before merge statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/613827#M179330</link>
      <description>&lt;P&gt;Practical example of "try it":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t1;
length x1 $10;
input x1;
datalines;
aaaaaaaa
bbbbbbbb
;

data t2;
length x1 $15;
input x1;
datalines;
cccccccccc
dddddddddd
;

data test1;
length x1 $5;
merge t1 t2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Replace the length in the final data step with arbitrary values, and inspect the resulting table. You will find that the value from the length statement always takes precedence.&lt;/P&gt;
&lt;P&gt;Please post the exam question and its answer for clarification.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Dec 2019 14:26:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/613827#M179330</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-25T14:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement before merge statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/613964#M179398</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/304679"&gt;@AdrianXavier&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;DIV class="_3xX726aBn29LDbsDtzr_6E _1Ap4F5maDtT1E1YuCiaO0r D3IL3FD0RFy_mkKLPwL4"&gt;
&lt;DIV class="_292iotee39Lmt0MkQZ2hPV RichTextJSON-root"&gt;
&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;Hi everyone! Can someone help me with this question? I took a practice SAS exam a couple days ago and there was this question that is absolutely driving me insane. The question was about using a length statement before the merge statement. I have always thought that if you add the length statement before the merge then the length statement chooses the length of the column. However, I got the answer wrong because apparently SAS uses the first table in the merge statement to choose the length and not the length statement even though it was written before. I feel like I am missing something here. Can someone help?&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="_1hwEKkB_38tIoal6fcdrt9"&gt;
&lt;DIV class="_3-miAEojrCvx_4FQ8x3P-s"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Example data.&lt;/P&gt;
&lt;P&gt;Example code&lt;/P&gt;
&lt;P&gt;Exact test of question and/or provided code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without concrete examples what you thought you read may not be what we think you are saying.&lt;/P&gt;
&lt;P&gt;And some "tests" are wrong with the answers.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Dec 2019 19:53:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/613964#M179398</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-12-26T19:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement before merge statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/613968#M179401</link>
      <description>&lt;P&gt;As you can see in&amp;nbsp;&lt;A href="https://communities.sas.com/t5/forums/editpage/board-id/certification/message-id/729" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/forums/editpage/board-id/certification/message-id/729&lt;/A&gt;&amp;nbsp;, "practice exams" from non-SAS sources can be misleading, causing you to fail in the actual exam.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Dec 2019 20:04:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/613968#M179401</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-26T20:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement before merge statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/621212#M182590</link>
      <description>&lt;P&gt;This question is from the&amp;nbsp;SAS Certification Practice Exam: SAS 9.4 Base Programming Performance-Based Exam (Q 29) via SAS e-learning/vle:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="formulation clearfix"&gt;&lt;DIV class="qtext"&gt;&lt;P&gt;The variable Name in the data set&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Employee&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;has a $CHAR10. format. The variable Name in the data set Sales has a $CHAR15. format.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following SAS program is submitted:&lt;/P&gt;&lt;PRE&gt;data both;
&amp;nbsp; &amp;nbsp;length name $ 20;
&amp;nbsp; &amp;nbsp;merge sales employee;
&amp;nbsp; &amp;nbsp;by id; 
run;&lt;/PRE&gt;What is the format for the variable Name in the data set&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Both&lt;/STRONG&gt;?&lt;BR /&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="ablock"&gt;&lt;DIV class="prompt"&gt;Select one:&lt;/DIV&gt;&lt;DIV class="answer"&gt;&lt;DIV class="r0 incorrect"&gt;&lt;SPAN class="answernumber"&gt;A.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;$20&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="r1"&gt;&lt;SPAN class="answernumber"&gt;B.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;$CHAR10&lt;/DIV&gt;&lt;DIV class="r0"&gt;&lt;SPAN class="answernumber"&gt;C.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;$CHAR15&lt;/DIV&gt;&lt;DIV class="r1"&gt;&lt;SPAN class="answernumber"&gt;D.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;$CHAR20&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="outcome clearfix"&gt;Feedback&lt;DIV class="feedback"&gt;&lt;DIV class="specificfeedback"&gt;Your answer (A) is incorrect.&lt;/DIV&gt;&lt;DIV class="generalfeedback"&gt;&lt;P&gt;The first attribute seen for a variable is the one used in the current data step. Given that the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Work.Sales&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;data set is positioned first on the MERGE statement, the variable&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;I&gt;Name&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/I&gt;would have a format of $CHAR15. in the new data set&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Work.Both&lt;/STRONG&gt;. The LENGTH statement only gives the variable&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;I&gt;Name&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/I&gt;a predefined maximum length.&lt;/P&gt;&lt;/DIV&gt;&lt;DIV class="rightanswer"&gt;The correct answer is: $CHAR15&lt;/DIV&gt;&lt;DIV class="rightanswer"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="rightanswer"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 30 Jan 2020 16:41:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/621212#M182590</guid>
      <dc:creator>jrboyle</dc:creator>
      <dc:date>2020-01-30T16:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement before merge statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/621216#M182593</link>
      <description>&lt;P&gt;If that is the question that the original poster was talking about then the last sentence in the answer explains the confusion that the original poster has.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;The format attached to a variable is independent of the length used to store that variable.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only place they intersect is when SAS is trying to figure out how to define the variable from the code of your data step. If the first place the variable is referenced is in a FORMAT&amp;nbsp;statement (or INFORMAT&amp;nbsp;statement or the FORMAT= or INFORMAT= attribute of an ATTRIB) then SAS will make the assumption/guess that you want the variable defined to have a type that is compatible with the format/informat and that the length should match the width of the format/informat specification.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 16:50:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/621216#M182593</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-01-30T16:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: Length statement before merge statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/621228#M182604</link>
      <description>&lt;P&gt;So the question is about a&amp;nbsp;&lt;STRONG&gt;&lt;FONT size="3"&gt;FORMAT&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT size="3"&gt;&lt;FONT size="2"&gt;, not a&amp;nbsp;&lt;STRONG&gt;&lt;FONT size="3"&gt;LENGTH&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT size="2"&gt;&lt;EM&gt;.&lt;/EM&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;This once again illustrates the importance of posting exact, precise questions.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;Maxim 42 in action.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 17:01:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Length-statement-before-merge-statement/m-p/621228#M182604</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-01-30T17:01:43Z</dc:date>
    </item>
  </channel>
</rss>

