<?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: Reading raw files in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/252578#M47981</link>
    <description>&lt;P&gt;Got it! Thank you so much for the clarification~~&lt;/P&gt;</description>
    <pubDate>Thu, 25 Feb 2016 23:20:53 GMT</pubDate>
    <dc:creator>lxn1021</dc:creator>
    <dc:date>2016-02-25T23:20:53Z</dc:date>
    <item>
      <title>Reading raw files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/252482#M47937</link>
      <description>&lt;P&gt;How many observations will be there in output dataset temp?&lt;BR /&gt;data temp;&lt;BR /&gt;x=4;&lt;BR /&gt;if x=5 then do;&lt;BR /&gt;y=2;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;a) 1&lt;BR /&gt;b) 2&lt;BR /&gt;c) 0&lt;BR /&gt;d) 3&lt;BR /&gt;Ans: c&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is the reason for this answer that as OUTPUT has been invoked, output will only be given if the condition is true and never otherwise?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2016 18:56:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/252482#M47937</guid>
      <dc:creator>Bulleride</dc:creator>
      <dc:date>2016-02-25T18:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: Reading raw files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/252488#M47941</link>
      <description>&lt;P&gt;Correct. Explicit 'output' disables implicit 'output' at the end of the data step. And when Explicit 'output'&amp;nbsp;is associate with a condition, then it depends on the condition whether there will be an output.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2016 19:05:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/252488#M47941</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-02-25T19:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: Reading raw files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/252493#M47946</link>
      <description>&lt;P&gt;Here,&amp;nbsp;&lt;EM&gt;output&amp;nbsp;&lt;/EM&gt;means "if x=5 then &lt;STRONG&gt;output the whole data set; else, do not output anything&lt;/STRONG&gt;".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you take away&amp;nbsp;&lt;EM&gt;output&lt;/EM&gt;,&amp;nbsp;like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;data temp;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; x=4;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if x=5 then do;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; y=2;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then there is a new data set~&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2016 19:13:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/252493#M47946</guid>
      <dc:creator>lxn1021</dc:creator>
      <dc:date>2016-02-25T19:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: Reading raw files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/252502#M47953</link>
      <description>Great! Thanks for adding up. I was thinking that the output will only be for that observation but now I know that the condition id for entire dataset. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Also when you say (in the case where we take away output) that there is a new dataset, then the new dataset is temp? right?</description>
      <pubDate>Thu, 25 Feb 2016 19:24:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/252502#M47953</guid>
      <dc:creator>Bulleride</dc:creator>
      <dc:date>2016-02-25T19:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: Reading raw files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/252508#M47958</link>
      <description>&lt;P&gt;Quote: "Here,&amp;nbsp;&lt;EM&gt;output&amp;nbsp;&lt;/EM&gt;means "if x=5 then &lt;STRONG&gt;output the whole data set; else, do not output anything&lt;/STRONG&gt;"."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This statement is a little bit confusing. 'output' statement only works on&amp;nbsp;ONE record that is residing in the PDV. It does not work on '&lt;STRONG&gt;whole data set', per se. I know you may mean it has systematic effect, here is just to clarify. &lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2016 19:30:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/252508#M47958</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-02-25T19:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: Reading raw files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/252514#M47961</link>
      <description>Thanks again for the clarification &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Thu, 25 Feb 2016 19:39:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/252514#M47961</guid>
      <dc:creator>Bulleride</dc:creator>
      <dc:date>2016-02-25T19:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: Reading raw files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/252578#M47981</link>
      <description>&lt;P&gt;Got it! Thank you so much for the clarification~~&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2016 23:20:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/252578#M47981</guid>
      <dc:creator>lxn1021</dc:creator>
      <dc:date>2016-02-25T23:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: Reading raw files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/252604#M47986</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; The title of the original post was "Reading raw files", which is not what the sample program shows. As an additional example, this program has 3 different steps, 1a, 1b and 2 and the values being read via DATALINES vary. In step 1a, the values being read in for X are never 5, so the output statement never gets executed so the first dataset has 0 obs (your original question)&amp;nbsp;and there is nothing for the PROC PRINT to print.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Then, step 1b is the same program, but this time, the data being read in via DATALINES has values for X that range from 3 to 6. So for 1 observation and ONLY 1 observation the condition X=5 is true, so Y is assigned a value of 2 and ONLY the observation for X=5 is output-- so now, the output dataset has 1 obs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Finally, in step 2, the values for X via DATALINES are the same as in the previous step, but, the OUTPUT statement is removed. As you can see in the results, only the row where X=5 has a value for Y. All the other rows have missing values for Y. But you can see that with the "explicit" OUTPUT statement removed, the implicit output at the bottom of the DATA step takes over. And so 4 datalines were read and 4 observations were written out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="courier new,courier" size="3"&gt;** here is the code;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="courier new,courier" size="3"&gt;&amp;nbsp; &lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="courier new,courier" size="3"&gt;** 1a) no values meet x=5 condition;&lt;BR /&gt;data temp_explicit_output_0rec; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; infile datalines;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; input x;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if x=5 then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y=2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;return;&lt;BR /&gt;datalines;&lt;BR /&gt;1 &lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;4&lt;BR /&gt;run;&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;proc print data=temp_explicit_output_0rec;&lt;BR /&gt;&amp;nbsp; title '1a) value of X goes from 1 to 4';&lt;BR /&gt;&amp;nbsp; title2 'No obs have x=5 so no obs are output and PROC PRINT fails';&lt;BR /&gt;run;&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;** 1b) have a value where x=5 condition will be true;&lt;BR /&gt;data temp_explicit_output; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; infile datalines;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; input x;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if x=5 then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y=2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;return;&lt;BR /&gt;datalines;&lt;BR /&gt;3&lt;BR /&gt;4&lt;BR /&gt;5&lt;BR /&gt;6&lt;BR /&gt;run;&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;proc print data=temp_explicit_output;&lt;BR /&gt;&amp;nbsp; title '1b) value of X goes from 3 to 6';&lt;BR /&gt;&amp;nbsp; title2 'explicit output if x=5 so only 1 obs is output';&lt;BR /&gt;run;&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;** 2) remove output statement and all 4 obs will be written;&lt;BR /&gt;** but only x=5 obs will have y=2;&lt;BR /&gt;data temp_implied_output; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; infile datalines;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; input x;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if x=5 then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y=2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;return;&lt;BR /&gt;datalines;&lt;BR /&gt;3&lt;BR /&gt;4&lt;BR /&gt;5&lt;BR /&gt;6&lt;BR /&gt;run;&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;proc print data=temp_implied_output;&lt;BR /&gt;&amp;nbsp; title '2) value of X goes from 3 to 6';&lt;BR /&gt;&amp;nbsp; title2 'every obs is output, but obs for 5 has y=2';&lt;BR /&gt;run;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Feb 2016 01:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/252604#M47986</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2016-02-26T01:20:16Z</dc:date>
    </item>
  </channel>
</rss>

