<?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 get the observations within a range. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-observations-within-a-range/m-p/273527#M58458</link>
    <description>&lt;P&gt;Another way:&lt;/P&gt;
&lt;PRE&gt;data want (drop=flag);
  set have;
  retain flag;
  if count=1 then flag=1;
  if count=2 then flag=.;
  if flag then output;
run;&lt;/PRE&gt;</description>
    <pubDate>Fri, 27 May 2016 08:51:09 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-05-27T08:51:09Z</dc:date>
    <item>
      <title>How to get the observations within a range.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-observations-within-a-range/m-p/273459#M58454</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Has anyone know how to get a specific range of data?&lt;/P&gt;
&lt;P&gt;For example, I have this dataset:&lt;/P&gt;
&lt;P&gt;Station &amp;nbsp;Year &amp;nbsp; &amp;nbsp; Month Day Temp Count&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp;3.2 &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; 4.2 &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; 3.5&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; 4&amp;nbsp; &amp;nbsp; &amp;nbsp; 3.7 &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; 5&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;2.1 &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; 6&amp;nbsp; &amp;nbsp; &amp;nbsp; 3.0&amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; 7&amp;nbsp; &amp;nbsp; &amp;nbsp; 2.2 &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; 8&amp;nbsp; &amp;nbsp; &amp;nbsp; 3.1 &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; 9&amp;nbsp; &amp;nbsp; &amp;nbsp; 2.3 &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; 10 &amp;nbsp; &amp;nbsp;3.2 &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;......&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I want to keep only the observations from count=1 to count=2, and I have several years and several stations.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for help!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hua&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2016 01:30:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-observations-within-a-range/m-p/273459#M58454</guid>
      <dc:creator>hua</dc:creator>
      <dc:date>2016-05-27T01:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the observations within a range.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-observations-within-a-range/m-p/273465#M58456</link>
      <description>&lt;P&gt;This should be workable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;do until (last.station);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;by station;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if count=1 then found_1='Y';&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if found_1='Y' and found_2 ne 'Y' then output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if count=2 then found_2='Y';&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;drop found_1 found_2;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2016 02:23:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-observations-within-a-range/m-p/273465#M58456</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-05-27T02:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the observations within a range.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-observations-within-a-range/m-p/273512#M58457</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Station  Year     Month Day Temp Count;
cards;
1           2000         1     1      3.2      .
1           2000         1     2      4.2      .
1           2000         1     3      3.5      1
1           2000         1     4      3.7      .
1           2000         1     5      2.1      .
1           2000         1     6      3.0      .
1           2000         1     7      2.2      2
1           2000         1     8      3.1      .
1           2000         1     9      2.3      .
1           2000         1     10    3.2      .
1           2001         1     1      3.2      1
1           2001         1     2      4.2      .
1           2001         1     3      3.5      1
1           2001         1     4      3.7      .
1           2001         1     5      2.1      .
1           2001         1     6      3.0      .
1           2001         1     7      2.2      2
1           2001         1     8      3.1      .
1           2001         1     9      2.3      .
1           2001         1     10    3.2      1
;
run;
data want;
do until(not missing(count) or last.Year);
 set have;
 by Station  Year;
 if first.Year then first=1;
end;
_count=count;
do until(not missing(count) or last.Year);
 set have;
 by Station  Year;
 if not first and not missing(_count) and missing(count)then output;
end;
drop _count first;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 May 2016 07:09:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-observations-within-a-range/m-p/273512#M58457</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-05-27T07:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the observations within a range.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-observations-within-a-range/m-p/273527#M58458</link>
      <description>&lt;P&gt;Another way:&lt;/P&gt;
&lt;PRE&gt;data want (drop=flag);
  set have;
  retain flag;
  if count=1 then flag=1;
  if count=2 then flag=.;
  if flag then output;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 May 2016 08:51:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-observations-within-a-range/m-p/273527#M58458</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-05-27T08:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the observations within a range.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-observations-within-a-range/m-p/275282#M58545</link>
      <description>It works very well. Thanks!</description>
      <pubDate>Mon, 06 Jun 2016 02:26:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-observations-within-a-range/m-p/275282#M58545</guid>
      <dc:creator>hua</dc:creator>
      <dc:date>2016-06-06T02:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the observations within a range.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-observations-within-a-range/m-p/275283#M58546</link>
      <description>Thank you for help! It helped me a lot!</description>
      <pubDate>Mon, 06 Jun 2016 02:26:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-observations-within-a-range/m-p/275283#M58546</guid>
      <dc:creator>hua</dc:creator>
      <dc:date>2016-06-06T02:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the observations within a range.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-observations-within-a-range/m-p/275284#M58547</link>
      <description>Thanks for reply! &lt;BR /&gt;Could you mind to tell me what does "retain" do? I always confusing about retain function.</description>
      <pubDate>Mon, 06 Jun 2016 02:28:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-the-observations-within-a-range/m-p/275284#M58547</guid>
      <dc:creator>hua</dc:creator>
      <dc:date>2016-06-06T02:28:45Z</dc:date>
    </item>
  </channel>
</rss>

