<?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: Number of observations are smaller then expected in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Number-of-observations-are-smaller-then-expected/m-p/488086#M127210</link>
    <description>&lt;P&gt;The first problem can be overcome by using an informat. The second requires some changes to the structure of your code. e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data banks;
  informat name $14.;
  input name rate;
  datalines;
FirstCapital 0.0718
DirectBank 0.0721
VirtualDirect 0.0728
;
run;

data newbank;
  set banks;
  do year = 1 to 3;
    capital + 5000;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Aug 2018 00:03:14 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2018-08-20T00:03:14Z</dc:date>
    <item>
      <title>Number of observations are smaller then expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Number-of-observations-are-smaller-then-expected/m-p/488084#M127209</link>
      <description>&lt;P&gt;Hi, here's my simple code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data banks;
input name $  rate;
datalines;
FirstCapital 0.0718
DirectBank 0.0721
VirtualDirect 0.0728
;
run;

data newbank;
do year = 1 to 3;
put year;
set banks;
capital + 5000;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It gives 1 observation with 4 variables.&lt;/P&gt;&lt;P&gt;I do understand 4 variables - year, name, rate, capital but not 1 observation.&lt;/P&gt;&lt;P&gt;year it repeating 3 times - and per a iteration banks ( 3 observations) are loaded into.&lt;/P&gt;&lt;P&gt;Thus should it have 3 times * 3 observations = 9 observations in total?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;P.S: 1 really really basic question. The code above doesnot fully embrace all character of 'name' field.&lt;/P&gt;&lt;P&gt;I have tried length name 15 but doesn't work. Is there any other way?&lt;/P&gt;</description>
      <pubDate>Sun, 19 Aug 2018 23:26:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Number-of-observations-are-smaller-then-expected/m-p/488084#M127209</guid>
      <dc:creator>jimmychoi</dc:creator>
      <dc:date>2018-08-19T23:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Number of observations are smaller then expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Number-of-observations-are-smaller-then-expected/m-p/488086#M127210</link>
      <description>&lt;P&gt;The first problem can be overcome by using an informat. The second requires some changes to the structure of your code. e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data banks;
  informat name $14.;
  input name rate;
  datalines;
FirstCapital 0.0718
DirectBank 0.0721
VirtualDirect 0.0728
;
run;

data newbank;
  set banks;
  do year = 1 to 3;
    capital + 5000;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Aug 2018 00:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Number-of-observations-are-smaller-then-expected/m-p/488086#M127210</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-08-20T00:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: Number of observations are smaller then expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Number-of-observations-are-smaller-then-expected/m-p/488113#M127222</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data newbank;
do year = 1 to 3;
put year;
set banks;
capital + 5000;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If there is no explicit output statement in a data step, the data step compiler adds an implicit one at the end of the code, so it would look like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data newbank;
do year = 1 to 3;
put year;
set banks;
capital + 5000;
end;
output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the first iteration of the data step, the do loop reads all 3 observations in the source data set, and the end state of the do loop is written to newbank. In the second iteration of the data step, it encounters a EOF condition in set banks in the first iteration of the do loop, and terminates without further output.&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;'s solution corrects all that by moving the set statement out of the loop (therefore only one read per datastep iteration), and adding the explicit output.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Aug 2018 07:22:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Number-of-observations-are-smaller-then-expected/m-p/488113#M127222</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-20T07:22:32Z</dc:date>
    </item>
  </channel>
</rss>

