<?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: Newbie with proc sql help with basic statements (mean, max, min, etc) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Newbie-with-proc-sql-help-with-basic-statements-mean-max-min-etc/m-p/603962#M175027</link>
    <description>I could see B being interpreted two ways, visits for patients who had a 50 or above in any visit, or number of visits with 50 and above. To me that one is ambiguous.</description>
    <pubDate>Wed, 13 Nov 2019 20:32:23 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-11-13T20:32:23Z</dc:date>
    <item>
      <title>Newbie with proc sql help with basic statements (mean, max, min, etc)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Newbie-with-proc-sql-help-with-basic-statements-mean-max-min-etc/m-p/603770#M174958</link>
      <description>&lt;P&gt;Hello experts, I'm starting to learn proc sql and I'm having trouble completing this exercise. I need to find:&lt;/P&gt;&lt;P&gt;a) How many patients by gender?&lt;/P&gt;&lt;P&gt;b) How many doctor visits for each patient with medical test score above 50?&lt;/P&gt;&lt;P&gt;c) what are mean, min, max scores for each patient?&lt;/P&gt;&lt;P&gt;d) list patients who have mean scores for all their visits larger than 45.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried to do part B so here is my code for part of this exercise, however I'm not getting the numbers I want:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;data record;&lt;BR /&gt;input ID $ Gender $ Age Score;&lt;BR /&gt;cards;&lt;BR /&gt;259632 F 56 58&lt;BR /&gt;259632 F 56 41&lt;BR /&gt;259632 F 56 39&lt;BR /&gt;577763 F 67 40&lt;BR /&gt;577763 F 67 50&lt;BR /&gt;577763 F 67 39&lt;BR /&gt;577763 F 67 33&lt;BR /&gt;279645 M 52 24&lt;BR /&gt;279645 M 52 65&lt;BR /&gt;279645 M 52 66&lt;BR /&gt;279645 M 52 74&lt;BR /&gt;279645 M 52 85&lt;BR /&gt;694797 F 48 37&lt;BR /&gt;694797 F 48 85&lt;BR /&gt;684516 M 57 81&lt;BR /&gt;760076 M 62 45&lt;BR /&gt;760076 M 62 35&lt;BR /&gt;760076 M 62 38&lt;BR /&gt;760076 M 62 65&lt;BR /&gt;745795 F 74 85&lt;BR /&gt;745795 F 74 82&lt;BR /&gt;745795 F 74 77&lt;BR /&gt;745795 F 74 81&lt;BR /&gt;506301 M 78 70&lt;BR /&gt;506301 M 78 70&lt;BR /&gt;506301 M 78 71&lt;BR /&gt;506301 M 78 67&lt;BR /&gt;406126 M 62 60&lt;BR /&gt;406126 M 62 50&lt;BR /&gt;477908 M 70 50&lt;BR /&gt;477908 M 70 63&lt;BR /&gt;477908 M 70 51&lt;BR /&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;select ID, count (distinct score)&lt;/P&gt;&lt;P&gt;as count&lt;/P&gt;&lt;P&gt;from record&lt;/P&gt;&lt;P&gt;where score&amp;gt;&lt;STRONG&gt;50&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;group by ID;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need some guidance on how to complete this exercise, please help!! Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 05:51:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Newbie-with-proc-sql-help-with-basic-statements-mean-max-min-etc/m-p/603770#M174958</guid>
      <dc:creator>user1942</dc:creator>
      <dc:date>2019-11-13T05:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie with proc sql help with basic statements (mean, max, min, etc)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Newbie-with-proc-sql-help-with-basic-statements-mean-max-min-etc/m-p/603785#M174967</link>
      <description>&lt;P&gt;a) select gender, count(distinct id) group by gender&lt;/P&gt;
&lt;P&gt;b) select id, count(id) group by id where score &amp;gt; 50&lt;/P&gt;
&lt;P&gt;c) select id, mean(score), min(score), max(score) group by id&lt;/P&gt;
&lt;P&gt;d) select id, mean(score) as score group by id having calculated score &amp;gt; 45&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 07:11:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Newbie-with-proc-sql-help-with-basic-statements-mean-max-min-etc/m-p/603785#M174967</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-13T07:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie with proc sql help with basic statements (mean, max, min, etc)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Newbie-with-proc-sql-help-with-basic-statements-mean-max-min-etc/m-p/603786#M174968</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*a*/
proc sql;
create table item_a as
select Gender, count (Gender) as count /*count the gender from the result of the sub query*/
from (select distinct ID, Gender from record) /*sub query to get distinct list of IDs and their gender, since there are multiple entries per ID*/
group by Gender;
quit;

/*b*/
proc sql;
create table item_b as
select ID, count (ID) as count_visits
from record
where score&amp;gt;50
group by ID;
quit;

/*c*/
proc sort data=record;
by ID Score; /*sort first*/
run;

proc means data=record;
var Score; /*we want to analyse score*/
by ID; /*for every value of ID*/
output out=item_c;
run;

/*d*/
proc sql;
create table item_d as 
select ID, Score as Mean 
from item_c /*let's take from the output in item c*/
where _STAT_ = 'Mean' and Score &amp;gt; 45;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Nov 2019 07:13:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Newbie-with-proc-sql-help-with-basic-statements-mean-max-min-etc/m-p/603786#M174968</guid>
      <dc:creator>sustagens</dc:creator>
      <dc:date>2019-11-13T07:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie with proc sql help with basic statements (mean, max, min, etc)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Newbie-with-proc-sql-help-with-basic-statements-mean-max-min-etc/m-p/603962#M175027</link>
      <description>I could see B being interpreted two ways, visits for patients who had a 50 or above in any visit, or number of visits with 50 and above. To me that one is ambiguous.</description>
      <pubDate>Wed, 13 Nov 2019 20:32:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Newbie-with-proc-sql-help-with-basic-statements-mean-max-min-etc/m-p/603962#M175027</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-13T20:32:23Z</dc:date>
    </item>
  </channel>
</rss>

