<?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: how to use by in %do in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-by-in-do/m-p/577956#M163849</link>
    <description>&lt;PRE&gt;obs=&lt;/PRE&gt;
&lt;P&gt;has to contain the physical number of the last observation to be read, not the number of observations you want to read&lt;/P&gt;
&lt;PRE&gt;firstobs=15 obs=28&lt;/PRE&gt;
&lt;P&gt;will read 14 observations, not 28.&lt;/P&gt;</description>
    <pubDate>Wed, 31 Jul 2019 06:35:26 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-07-31T06:35:26Z</dc:date>
    <item>
      <title>how to use by in %do</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-by-in-do/m-p/577953#M163848</link>
      <description>&lt;P&gt;I want to get&amp;nbsp;one part of the data and calculate every time. for example, first time obs: 1 to 14, second time obs: 15 to 28 etc.&lt;/P&gt;&lt;P&gt;I&amp;nbsp; use a macro&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; agestd_one(number);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;number &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%by&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;14&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data import;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;set T0314(firstobs=&amp;amp;i obs=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;14&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;I run:&lt;/FONT&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%&lt;STRONG&gt;&lt;I&gt;agestd_one&lt;/I&gt;&lt;/STRONG&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;14&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;works well.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;I run:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%&lt;STRONG&gt;&lt;I&gt;agestd_one&lt;/I&gt;&lt;/STRONG&gt;(&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;28&lt;/FONT&gt;&lt;/STRONG&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;error message:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;ERROR: FIRSTOBS option &amp;gt; OBS option - no data to read from file WORK.T0314.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what wrong at here?&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 06:19:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-by-in-do/m-p/577953#M163848</guid>
      <dc:creator>walterwang</dc:creator>
      <dc:date>2019-07-31T06:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: how to use by in %do</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-by-in-do/m-p/577956#M163849</link>
      <description>&lt;PRE&gt;obs=&lt;/PRE&gt;
&lt;P&gt;has to contain the physical number of the last observation to be read, not the number of observations you want to read&lt;/P&gt;
&lt;PRE&gt;firstobs=15 obs=28&lt;/PRE&gt;
&lt;P&gt;will read 14 observations, not 28.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 06:35:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-by-in-do/m-p/577956#M163849</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-31T06:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: how to use by in %do</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-by-in-do/m-p/577958#M163851</link>
      <description>&lt;P&gt;You fell into a violation of the basic macro development principle: start with working code.&lt;/P&gt;
&lt;P&gt;If you had tried&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;firstobs=28 obs=14&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in Base SAS without the macro around it, you would have encountered the problem there, and not thought that your macro code is the culprit.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 06:38:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-by-in-do/m-p/577958#M163851</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-31T06:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to use by in %do</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-by-in-do/m-p/577960#M163853</link>
      <description>&lt;P&gt;A suggestion for your macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro agestd_one(number);
%do start=1 %to &amp;amp;number %by 14;
  %let end=%eval(&amp;amp;start+13);

data import;
set T0314 (firstobs=&amp;amp;start. obs=&amp;amp;end.);
run;

%end;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Jul 2019 06:43:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-by-in-do/m-p/577960#M163853</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-31T06:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to use by in %do</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-by-in-do/m-p/577964#M163856</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; we really need an alias&amp;nbsp; lastobs=&amp;nbsp; for the&amp;nbsp; obs=&amp;nbsp; option.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 06:55:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-by-in-do/m-p/577964#M163856</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-07-31T06:55:19Z</dc:date>
    </item>
  </channel>
</rss>

