<?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 I only output the instances where the subject has the highest level? (example included) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-I-only-output-the-instances-where-the-subject-has-the/m-p/811397#M320030</link>
    <description>&lt;PRE&gt;data have1;
infile datalines dsd dlm=",";
	input subj $ treatment $ painlvl bodypart $;
datalines;
001, A, 1, leg
001, A, 2, leg
002, B, 1, head
003, A, 1, arm
004, B, 1, eye
005, B, 2, mouth
; 
run;


proc sql;
create table want as
select * from have1
 group by subj
  having painlvl=max(painlvl);
quit;&lt;/PRE&gt;</description>
    <pubDate>Wed, 04 May 2022 09:40:40 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2022-05-04T09:40:40Z</dc:date>
    <item>
      <title>How to I only output the instances where the subject has the highest level? (example included)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-I-only-output-the-instances-where-the-subject-has-the/m-p/811340#M319994</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have1;
infile datalines dsd dlm=",";
	input subj $ treatment $ painlvl bodypart $;
datalines;
001, A, 1, leg
001, A, 2, leg
002, B, 1, head
003, A, 1, arm
004, B, 1, eye
005, B, 2, mouth
; 
run; * choose distinct subjects with highest severity (if more than one instance);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;information:&lt;/P&gt;
&lt;P&gt;* 6 obs&lt;/P&gt;
&lt;P&gt;* n=5&lt;/P&gt;
&lt;P&gt;* 2 treatment groups (A, B)&lt;/P&gt;
&lt;P&gt;Goal: 001 has two reported painful observations in the same area (leg), and the goal is to&lt;/P&gt;
&lt;P&gt;output the row where he has the highest pain level, so that my resultant data set will include 5 rows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could I receive some help? I tried PROC SQL and using the max() paired w/ the group by clause. It worked but I received an error.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2022 22:55:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-I-only-output-the-instances-where-the-subject-has-the/m-p/811340#M319994</guid>
      <dc:creator>Hello_there</dc:creator>
      <dc:date>2022-05-03T22:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to I only output the instances where the subject has the highest level? (example included)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-I-only-output-the-instances-where-the-subject-has-the/m-p/811355#M320004</link>
      <description>&lt;P&gt;Help us help you.&amp;nbsp; Please show the log including the code and the error message it produced.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the "&amp;lt;/&amp;gt;" icon to make a text box for that content.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 03:20:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-I-only-output-the-instances-where-the-subject-has-the/m-p/811355#M320004</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-05-04T03:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to I only output the instances where the subject has the highest level? (example included)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-I-only-output-the-instances-where-the-subject-has-the/m-p/811357#M320006</link>
      <description>I don't know if it was an error, but it said something to the effect of not liking me using a summary function when trying to group by subject when i was selecting count(distinct subject).&lt;BR /&gt;&lt;BR /&gt;Anyways, i found a data step way to do it which is to sort by subj treatment bodypart desecnding painlvl, and then proc sort again by subj nodupkey.&lt;BR /&gt;&lt;BR /&gt;Thanks anway though</description>
      <pubDate>Wed, 04 May 2022 03:25:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-I-only-output-the-instances-where-the-subject-has-the/m-p/811357#M320006</guid>
      <dc:creator>Hello_there</dc:creator>
      <dc:date>2022-05-04T03:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to I only output the instances where the subject has the highest level? (example included)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-I-only-output-the-instances-where-the-subject-has-the/m-p/811397#M320030</link>
      <description>&lt;PRE&gt;data have1;
infile datalines dsd dlm=",";
	input subj $ treatment $ painlvl bodypart $;
datalines;
001, A, 1, leg
001, A, 2, leg
002, B, 1, head
003, A, 1, arm
004, B, 1, eye
005, B, 2, mouth
; 
run;


proc sql;
create table want as
select * from have1
 group by subj
  having painlvl=max(painlvl);
quit;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 May 2022 09:40:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-I-only-output-the-instances-where-the-subject-has-the/m-p/811397#M320030</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-05-04T09:40:40Z</dc:date>
    </item>
  </channel>
</rss>

