<?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 maximum and minimum reading for a person with respective dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-maximum-and-minimum-reading-for-a-person-with/m-p/309069#M66443</link>
    <description>&lt;P&gt;Data step solution:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=test;
by id;
run;

data want;
set test;
by id;
retain max_bp date_having_max_bp min_bp date_having_min_bp;
format date_having_max_bp date_having_min_bp yymmddn8.;
if first.id
then do;
  max_bp = 0;
  min_bp = 1000;
end;
if bp &amp;gt; max_bp
then do;
  max_bp = bp;
  date_having_max_bp = date;
end;
if bp &amp;lt; min_bp
then do;
  min_bp = bp;
  date_having_min_bp = date;
end;
if last.id then output;
keep id max_bp date_having_max_bp min_bp date_having_min_bp;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS:&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9﻿&lt;/a&gt;'s solution beats mine. Much neater. &lt;/P&gt;</description>
    <pubDate>Thu, 03 Nov 2016 15:45:25 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-11-03T15:45:25Z</dc:date>
    <item>
      <title>How to get maximum and minimum reading for a person with respective dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-maximum-and-minimum-reading-for-a-person-with/m-p/309061#M66439</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I am trying to generate record of each person having maximum and minimum bp with respective dates. Sample of dataset is as follows:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input id bp date $ ;
cards;
1 100 20160110
2 110 20160111
3 150 20160112
1 110 20160112
2 130 20160113
3 130 20160114
1 140 20160113
2 150 20160114
3 120 20160115
1 120 20160114
2 120 20160115
3 160 20160116
1 150 20160115
2 140 20160116
3 130 20160117
;
run;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Wanted:&lt;/P&gt;&lt;P&gt;id &amp;nbsp; &amp;nbsp;max_bp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; date_having_max_bp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; min_bp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; date_having_min_bp&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; 150 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20160115 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20160110&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can somebody help me to do that. Thank you in advance for your kind reply.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 15:29:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-maximum-and-minimum-reading-for-a-person-with/m-p/309061#M66439</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2016-11-03T15:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to get maximum and minimum reading for a person with respective dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-maximum-and-minimum-reading-for-a-person-with/m-p/309065#M66442</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;PRE&gt;proc sort data=test;
  by id bp;
run;

data want (drop=bp date);
  set test;
  by id;
  retain min_bp min_date_bp max_bp max_date_bp;
  if first.id then do;
    min_bp=bp;
    min_date_bp=date;
  end;
  if last.id then do;
    max_bp=bp;
    max_date_bp=date;
    output;
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Nov 2016 15:36:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-maximum-and-minimum-reading-for-a-person-with/m-p/309065#M66442</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-11-03T15:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to get maximum and minimum reading for a person with respective dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-maximum-and-minimum-reading-for-a-person-with/m-p/309069#M66443</link>
      <description>&lt;P&gt;Data step solution:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=test;
by id;
run;

data want;
set test;
by id;
retain max_bp date_having_max_bp min_bp date_having_min_bp;
format date_having_max_bp date_having_min_bp yymmddn8.;
if first.id
then do;
  max_bp = 0;
  min_bp = 1000;
end;
if bp &amp;gt; max_bp
then do;
  max_bp = bp;
  date_having_max_bp = date;
end;
if bp &amp;lt; min_bp
then do;
  min_bp = bp;
  date_having_min_bp = date;
end;
if last.id then output;
keep id max_bp date_having_max_bp min_bp date_having_min_bp;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS:&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9﻿&lt;/a&gt;'s solution beats mine. Much neater. &lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 15:45:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-maximum-and-minimum-reading-for-a-person-with/m-p/309069#M66443</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-11-03T15:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to get maximum and minimum reading for a person with respective dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-maximum-and-minimum-reading-for-a-person-with/m-p/309070#M66444</link>
      <description>&lt;P&gt;One way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=test noprint nway;
   class id;
   var bp;
   output out=want (drop= _:)
     max= idgroup(max(bp) out[1] (date)=DateBpMax)
     min= idgroup(Min(bp) out[1] (date)=DateBPMin)
     /autolabel autoname;
run;
proc print noobs label;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Nway suppresses an over max min across the ID values.&lt;/P&gt;
&lt;P&gt;I didn't force to your variable names. There some pretty good reasons to use the statistic as a suffix depending on later processing needs.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 15:46:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-maximum-and-minimum-reading-for-a-person-with/m-p/309070#M66444</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-11-03T15:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to get maximum and minimum reading for a person with respective dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-maximum-and-minimum-reading-for-a-person-with/m-p/309074#M66445</link>
      <description>&lt;P&gt;Thank you for your quick reply as well as for providing solution in very simple language.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 15:53:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-maximum-and-minimum-reading-for-a-person-with/m-p/309074#M66445</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2016-11-03T15:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to get maximum and minimum reading for a person with respective dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-maximum-and-minimum-reading-for-a-person-with/m-p/309078#M66447</link>
      <description>&lt;P&gt;Thank you for providing me an alternative way to address my reporting process.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 15:58:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-maximum-and-minimum-reading-for-a-person-with/m-p/309078#M66447</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2016-11-03T15:58:29Z</dc:date>
    </item>
  </channel>
</rss>

