<?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: which choice is correct? why ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/which-choice-is-correct-why/m-p/736979#M229704</link>
    <description>&lt;P&gt;yes, you are right, actually, at the begin, I think that there are no difference between the data(5 2, 3 1, 5 6)in a sas data set and in datalines. but later, I just find they are different between them---if we want to use the datallines, we need to add input statement, otherwise , we don't . why ?&lt;/P&gt;
&lt;P&gt;the former , I get the following:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tianerhu_0-1619442254967.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58683i13E600CDC530D10B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tianerhu_0-1619442254967.png" alt="tianerhu_0-1619442254967.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;and the latter， I get the correct answer is A , why ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Apr 2021 13:06:26 GMT</pubDate>
    <dc:creator>tianerhu</dc:creator>
    <dc:date>2021-04-26T13:06:26Z</dc:date>
    <item>
      <title>which choice is correct? why ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/which-choice-is-correct-why/m-p/736962#M229698</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sasuser.one sasuser.two other;
   infile datalines;
   if x eq 5 then output sasuser.one;
   if y lt 5 then output sasuser.two;
   output;
datalines;
5 2
3 1
5 6 
;
run;
title 'sasuser.on';
proc print data = sasuser.one;
run;
title 'sasuser.t';
proc print data = sasuser.two;
run;
title 'other';
proc print data = other;
run;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tianerhu_0-1619439514430.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58679i66E3DBA8B1664952/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tianerhu_0-1619439514430.png" alt="tianerhu_0-1619439514430.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Apr 2021 12:18:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/which-choice-is-correct-why/m-p/736962#M229698</guid>
      <dc:creator>tianerhu</dc:creator>
      <dc:date>2021-04-26T12:18:55Z</dc:date>
    </item>
    <item>
      <title>Re: which choice is correct? why ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/which-choice-is-correct-why/m-p/736967#M229699</link>
      <description>&lt;P&gt;Wow, someone has come up with a totally unrealistic question designed to be extremely tricky for beginning students. Whoever created this question should be ashamed. Speaking as a non-beginner, I have no idea what this does, or why it happens, as I have never once in over 800 years of programming in SAS used INFILE without an INPUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 12:32:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/which-choice-is-correct-why/m-p/736967#M229699</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-26T12:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: which choice is correct? why ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/which-choice-is-correct-why/m-p/736976#M229702</link>
      <description>A</description>
      <pubDate>Mon, 26 Apr 2021 12:51:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/which-choice-is-correct-why/m-p/736976#M229702</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-04-26T12:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: which choice is correct? why ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/which-choice-is-correct-why/m-p/736979#M229704</link>
      <description>&lt;P&gt;yes, you are right, actually, at the begin, I think that there are no difference between the data(5 2, 3 1, 5 6)in a sas data set and in datalines. but later, I just find they are different between them---if we want to use the datallines, we need to add input statement, otherwise , we don't . why ?&lt;/P&gt;
&lt;P&gt;the former , I get the following:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tianerhu_0-1619442254967.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58683i13E600CDC530D10B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tianerhu_0-1619442254967.png" alt="tianerhu_0-1619442254967.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;and the latter， I get the correct answer is A , why ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 13:06:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/which-choice-is-correct-why/m-p/736979#M229704</guid>
      <dc:creator>tianerhu</dc:creator>
      <dc:date>2021-04-26T13:06:26Z</dc:date>
    </item>
    <item>
      <title>Re: which choice is correct? why ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/which-choice-is-correct-why/m-p/736980#M229705</link>
      <description>&lt;P&gt;Thank you ,&amp;nbsp; could you tell me why the answer is A ?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 13:07:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/which-choice-is-correct-why/m-p/736980#M229705</guid>
      <dc:creator>tianerhu</dc:creator>
      <dc:date>2021-04-26T13:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: which choice is correct? why ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/which-choice-is-correct-why/m-p/736983#M229708</link>
      <description>&lt;P&gt;For the code as posted none of the answers is right.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1501  data sasuser.one sasuser.two other;
1502     infile datalines;
1503     if x eq 5 then output sasuser.one;
1504     if y lt 5 then output sasuser.two;
1505     output;
1506  datalines;

NOTE: Variable x is uninitialized.
NOTE: Variable y is uninitialized.
NOTE: The data set SASUSER.ONE has 1 observations and 2 variables.
NOTE: The data set SASUSER.TWO has 2 observations and 2 variables.
NOTE: The data set WORK.OTHER has 1 observations and 2 variables.
&lt;/PRE&gt;
&lt;P&gt;Assuming that we add an INPUT statement before the first IF (or just replaces the INFILE statement) that reads the two columns of data into the variables X and Y then A is the right answer.&lt;/P&gt;
&lt;PRE&gt;1511  data sasuser.one sasuser.two other;
1512     input X Y ;
1513     if x eq 5 then output sasuser.one;
1514     if y lt 5 then output sasuser.two;
1515     output;
1516  datalines;

NOTE: The data set SASUSER.ONE has 5 observations and 2 variables.
NOTE: The data set SASUSER.TWO has 5 observations and 2 variables.
NOTE: The data set WORK.OTHER has 3 observations and 2 variables.
&lt;/PRE&gt;
&lt;P&gt;The last OUTPUT statement will write one observation per line of data read to all three output datasets.&lt;/P&gt;
&lt;P&gt;So each output dataset will get at least 3 observations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As to why the first two datasets each get an additional two observations look at the IF conditions and see how many times they are true so that the the extra output statements that write to just one of the datasets runs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 13:24:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/which-choice-is-correct-why/m-p/736983#M229708</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-26T13:24:18Z</dc:date>
    </item>
    <item>
      <title>Re: which choice is correct? why ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/which-choice-is-correct-why/m-p/737000#M229713</link>
      <description>Hi:&lt;BR /&gt;  If you found this question in one of the SAS Prep Guides, please send the book information (such as ISBN number and exact title) to Certification@sas.com so they can fix the publication or update the errata. (they'll need the book title, the ISBN, the page number with the question and the page number with the question solution).&lt;BR /&gt;&lt;BR /&gt;  My guess, however, is that this is either a very old Prep Guide or a sample question not written by SAS but from someone else's web site. We used to show test code writing to SASUSER (a long time ago) but stopped that practice because on EG, and on University Edition and SAS OnDemand users do NOT have write access to SASUSER and so code like this won't work. Several years ago, we changed our Prep Guide examples NOT to use SASUSER, so this is why I think there is something "off" with this question.&lt;BR /&gt;&lt;BR /&gt;  If you DID have an INPUT statement for X and Y, then the correct answer would be A, as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; has indicated. But, as written, none of the answers are correct.&lt;BR /&gt;&lt;BR /&gt;Cynthia</description>
      <pubDate>Mon, 26 Apr 2021 14:40:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/which-choice-is-correct-why/m-p/737000#M229713</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2021-04-26T14:40:10Z</dc:date>
    </item>
    <item>
      <title>Re: which choice is correct? why ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/which-choice-is-correct-why/m-p/737032#M229723</link>
      <description>&lt;P&gt;Thank you very much for telling . I appreciate.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 16:08:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/which-choice-is-correct-why/m-p/737032#M229723</guid>
      <dc:creator>tianerhu</dc:creator>
      <dc:date>2021-04-26T16:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: which choice is correct? why ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/which-choice-is-correct-why/m-p/737034#M229724</link>
      <description>&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 16:11:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/which-choice-is-correct-why/m-p/737034#M229724</guid>
      <dc:creator>tianerhu</dc:creator>
      <dc:date>2021-04-26T16:11:16Z</dc:date>
    </item>
  </channel>
</rss>

