<?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: IF FIRST.ID with Proc SQL in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862844#M42497</link>
    <description>&lt;P&gt;I think you're over thinking this....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 

Create table AVG_SCORE_TABLE as

Select name, mean (score) as AVG_SCORE, min(Score) as MIN_SCORE  

from readin1

Group by name

Order by AVG_SCORE DESC;

QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 07 Mar 2023 23:10:38 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2023-03-07T23:10:38Z</dc:date>
    <item>
      <title>IF FIRST.ID with Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862748#M42481</link>
      <description>&lt;P&gt;Is there any way to get IF First.ID result with PROC SQL?&lt;/P&gt;&lt;P&gt;Please let me know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data readin;&lt;BR /&gt;input ID Name $ Score;&lt;BR /&gt;cards;&lt;BR /&gt;1 David 45&lt;BR /&gt;1 David 74&lt;BR /&gt;2 Sam 45&lt;BR /&gt;2 Ram 54&lt;BR /&gt;3 Bane 87&lt;BR /&gt;3 Mary 92&lt;BR /&gt;3 Bane 87&lt;BR /&gt;4 Dane 23&lt;BR /&gt;5 Jenny 87&lt;BR /&gt;5 Ken 87&lt;BR /&gt;6 Simran 63&lt;BR /&gt;8 Priya 72&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;PROC SORT DATA = READIN;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;BY ID;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RUN;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;DATA READIN1;&lt;BR /&gt;SET READIN;&lt;BR /&gt;BY ID;&lt;BR /&gt;&lt;STRONG&gt;IF FIRST.ID&lt;/STRONG&gt;;&lt;BR /&gt;PROC PRINT;&lt;BR /&gt;RUN;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Desired output: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LucasW_0-1678213075074.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/81168i1E30F9EEC8D75762/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LucasW_0-1678213075074.png" alt="LucasW_0-1678213075074.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Thank you!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 18:18:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862748#M42481</guid>
      <dc:creator>LucasW</dc:creator>
      <dc:date>2023-03-07T18:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: IF FIRST.ID with Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862758#M42482</link>
      <description>&lt;P&gt;In general, no. There is no given order that SQL will return records.&lt;/P&gt;
&lt;P&gt;If there is another, or a combination of other variables, that control order, such as a DATE or sequence number you might be able to restrict the output using a HAVING clause with the minimum of that value(better be a numeric value, character minimums seldom match expectations).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you example data had a variable like test number something like this:&lt;/P&gt;
&lt;PRE&gt;data readin;
input ID Name $ Score test;
cards;
1 David 45 1
1 David 74 2
2 Sam 45   3
2 Ram 54   4
3 Bane 87  5
3 Mary 92  6
3 Bane 87  7
4 Dane 23  8
5 Jenny 87 9
5 Ken 87   10
6 Simran 63 11 
8 Priya 72  12
;
run;

proc sql;
   create table want as
   select *
   from readin
   group by id
   having test=min(test)
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;It would make more sense to have sequence for each ID but they don't have to be such and the above was easy to enter in the editor since your values were grouped in the data step (thank you).&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>Tue, 07 Mar 2023 18:42:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862758#M42482</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-07T18:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: IF FIRST.ID with Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862774#M42483</link>
      <description>&lt;P&gt;Why bother? The DATA step gives you the result with very little coding while SQL needs additional effort, so stay with it.&lt;/P&gt;
&lt;P&gt;Maxim 14. Use the Right Tool.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 19:54:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862774#M42483</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-07T19:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: IF FIRST.ID with Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862792#M42484</link>
      <description>&lt;P&gt;I totally get it what both of you are saying, that's why after researching a lot, I ended up asking here.&lt;/P&gt;&lt;P&gt;It is not the first time that I receive a reply saying it is not possible to do this or that with Proc SQL... I guess my teacher have no clue what he is asking for... and probably he is not an expert on the subject himself... Difficult will be for me to question him about it without saying that I asked a ton of experts...&amp;nbsp; Thank you a lot&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 20:30:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862792#M42484</guid>
      <dc:creator>LucasW</dc:creator>
      <dc:date>2023-03-07T20:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: IF FIRST.ID with Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862796#M42485</link>
      <description>&lt;P&gt;The current SAS program code does make a lot of sense.&amp;nbsp; The question would make more sense if you were sorting by some other variable in addition to ID.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if the goal is to find the minimum (or maximum) SCORE for each ID then just tell PROC SQL to do that and forget about FIRST. processing.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table readin1 as 
  select id,name, min(score) as score
  from readin
  group by id,name
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 20:39:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862796#M42485</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-07T20:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: IF FIRST.ID with Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862811#M42486</link>
      <description>&lt;P&gt;Hi Tom,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to include Min or Max if I already have another query in between? In my task I have to create an extra column with the average, and then if there is a duplicate, I need to keep the row that had the min original score, example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create table readin1 as&lt;/P&gt;&lt;P&gt;Select id, name, mean (score) as score_average, min(score) as score&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;from readin1&lt;/P&gt;&lt;P&gt;Group by id, name;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 21:16:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862811#M42486</guid>
      <dc:creator>LucasW</dc:creator>
      <dc:date>2023-03-07T21:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: IF FIRST.ID with Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862813#M42487</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440347"&gt;@LucasW&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Tom,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it possible to include Min or Max if I already have another query in between? In my task I have to create an extra column with the average, and then if there is a duplicate, I need to keep the row that had the min original score, example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create table readin1 as&lt;/P&gt;
&lt;P&gt;Select id, name, mean (score) as score_average, min(score) as score&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;from readin1&lt;/P&gt;
&lt;P&gt;Group by id, name;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The new request does not make any sense either.&amp;nbsp; If you want the average and&amp;nbsp; the minimum your code is fine.&amp;nbsp; I do not see how ties come into the question.&amp;nbsp; If you collapse to one observation per group there is nothing that can be tied.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might want to show example input and the expected example. Make sure to include cases that test the boundary conidiations of your logic.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 21:21:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862813#M42487</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-07T21:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: IF FIRST.ID with Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862824#M42488</link>
      <description>&lt;P&gt;Hi Tom,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry to not return with a table. Below is the question that I received, I hope it clarifies:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With PROC SQL, find the average SCORE present in the data, in a single query. Call the column containing the result AVG_SCORE and store the result in a table called AVG_SCORE_TABLE.&lt;BR /&gt;NOTE: A student (NAME) can be present twice, in this case, remember only keep the minimum score recorded.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far the code that I did worked (below), but the I have duplicate rows with only the SCORE column with different values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create table AVG_SCORE_TABLE as&lt;/P&gt;&lt;P&gt;Select name, score, mean (score) as AVG_SCORE&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;from readin1&lt;/P&gt;&lt;P&gt;Group by name, score&lt;/P&gt;&lt;P&gt;Order by AVG_SCORE DESC;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know where to include the query to keep only the minimum score.&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 21:51:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862824#M42488</guid>
      <dc:creator>LucasW</dc:creator>
      <dc:date>2023-03-07T21:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: IF FIRST.ID with Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862830#M42490</link>
      <description>&lt;P&gt;From this description:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;With PROC SQL, find the average SCORE present in the data, in a single query. Call the column containing the result AVG_SCORE and store the result in a table called AVG_SCORE_TABLE.&lt;BR /&gt;NOTE: A student (NAME) can be present twice, in this case, remember only keep the minimum score recorded.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think the answer will be table with a single row, correct?&amp;nbsp; For example, you would select the minimum score for each student, and then calculate the average of those scores.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is that what you want?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you learned about using sub-queries in PROC SQL?&amp;nbsp; This sounds like a problem where you could use a subquery to calculate the minimum score for each student, then the main query could calculate the average of those scores.&amp;nbsp; Would a query with a sub-query count as a single query?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 22:04:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862830#M42490</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-03-07T22:04:40Z</dc:date>
    </item>
    <item>
      <title>Re: IF FIRST.ID with Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862839#M42493</link>
      <description>&lt;P&gt;That is more straight forward.&amp;nbsp; You want the average of the minimums.&lt;/P&gt;
&lt;P&gt;The logic to find the minimum you already had, but you don't need both the ID and the NAME,&amp;nbsp; just enough to unique identify the grouping.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select id,min(score) as min_score from HAVE group by id&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you just need use that as the input to tha query to find the average.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming that you want estimate the "average" using the MEAN statistic (as opposed to some other statistic such as MEDIAN) you would do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table as AVG_SCORE_TABLE 
  select mean(min_score) as &lt;SPAN&gt;AVG_SCORE&lt;/SPAN&gt;
  from (select id, min(score) as min_score from HAVE group by id)
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Mar 2023 22:36:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862839#M42493</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-07T22:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: IF FIRST.ID with Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862840#M42494</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've learned only simple sub-queries, but I believe it counts as one query. Unfortunately, the school I'm in has a tendency the teach the simple stuff and then request on exams tasks that were never saw in class... They say we need to figure it out ourselves...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, with the code that I did, I got this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;TABLE border="1" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;ID&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Name&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Score&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;AVG_SCORE&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;David&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;45&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;59.5&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;David&lt;/P&gt;&lt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gt;But I need to eliminate the duplicate students and keep the lowest score, like this:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;TABLE border="1" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;ID&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Name&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Score&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;AVG_SCORE&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;David&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;45&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;59.5&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Sam&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;45&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;45&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Ram&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;54&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;54&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Bane&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;87&lt;/P&gt;&lt;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t;10&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Priya&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;72&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;72&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 07 Mar 2023 22:37:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862840#M42494</guid>
      <dc:creator>LucasW</dc:creator>
      <dc:date>2023-03-07T22:37:10Z</dc:date>
    </item>
    <item>
      <title>Re: IF FIRST.ID with Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862844#M42497</link>
      <description>&lt;P&gt;I think you're over thinking this....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 

Create table AVG_SCORE_TABLE as

Select name, mean (score) as AVG_SCORE, min(Score) as MIN_SCORE  

from readin1

Group by name

Order by AVG_SCORE DESC;

QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Mar 2023 23:10:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862844#M42497</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-03-07T23:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: IF FIRST.ID with Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862845#M42498</link>
      <description>&lt;P&gt;Hmm, Tom's solution is what I was thinking, and matches the description of the problem as I would read it.&amp;nbsp; But Reeza's solution matches the table you want.&amp;nbsp; So I think you'll be happy with one of those. : )&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 23:32:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862845#M42498</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-03-07T23:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: IF FIRST.ID with Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862847#M42499</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;thank you soooo much!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 23:43:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-FIRST-ID-with-Proc-SQL/m-p/862847#M42499</guid>
      <dc:creator>LucasW</dc:creator>
      <dc:date>2023-03-07T23:43:50Z</dc:date>
    </item>
  </channel>
</rss>

