<?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: select rows within different groups in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/select-rows-within-different-groups/m-p/339271#M77403</link>
    <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much for your help! It works!!&lt;/P&gt;&lt;P&gt;But can I have other ways, like proc sql, to solve this question?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;Chen&lt;/P&gt;</description>
    <pubDate>Wed, 08 Mar 2017 15:16:05 GMT</pubDate>
    <dc:creator>echoli</dc:creator>
    <dc:date>2017-03-08T15:16:05Z</dc:date>
    <item>
      <title>select rows within different groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-rows-within-different-groups/m-p/339047#M77325</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a problem about how select rows of what I want:&lt;/P&gt;&lt;P&gt;for example, I have several subjects with several variables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;group id timepoint&lt;/P&gt;&lt;P&gt;TX &amp;nbsp; &amp;nbsp; &amp;nbsp;01 &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;TX &amp;nbsp; &amp;nbsp; &amp;nbsp;01 &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00FF00"&gt;TX &amp;nbsp; &amp;nbsp; &amp;nbsp;02 &amp;nbsp; &amp;nbsp; 1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;TX &amp;nbsp; &amp;nbsp; &amp;nbsp;03 &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;TX &amp;nbsp; &amp;nbsp; &amp;nbsp;04 &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00FF00"&gt;CT &amp;nbsp; &amp;nbsp; &amp;nbsp;05 &amp;nbsp; &amp;nbsp; 1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00FF00"&gt;CT &amp;nbsp; &amp;nbsp; &amp;nbsp;06 &amp;nbsp; &amp;nbsp; 2&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to select id(s) in TX group but have timepoint 1 and 2 simultaneously. That means I want to delete rows with highlight green color. Anyone has a good idea if I want to use proc sql? Or other ways are okay.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;Chen&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2017 23:13:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-rows-within-different-groups/m-p/339047#M77325</guid>
      <dc:creator>echoli</dc:creator>
      <dc:date>2017-03-07T23:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: select rows within different groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-rows-within-different-groups/m-p/339056#M77327</link>
      <description>&lt;P&gt;Is it only 1 &amp;amp; 2 or could you have duplicates or 1/2/3?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it's only 1 &amp;amp; 2 then this works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;

by group id; *may need to sort your data first;

if not (first.id and last.id); *if unique then a record is first and last at same time;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Mar 2017 23:40:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-rows-within-different-groups/m-p/339056#M77327</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-07T23:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: select rows within different groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-rows-within-different-groups/m-p/339093#M77341</link>
      <description>&lt;P&gt;It is not clear to me why you keep id=03 and id=04. Id=03 only has timepoint=1 and id=04 only has timepoint=2. Neither has timepoints 1 and 2 simultaneously. What am I missing?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 04:24:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-rows-within-different-groups/m-p/339093#M77341</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-03-08T04:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: select rows within different groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-rows-within-different-groups/m-p/339270#M77402</link>
      <description>&lt;P&gt;Hi PG,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Very sorry that I made mistakes in my example, the correct example should be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;group &amp;nbsp; id &amp;nbsp; &amp;nbsp;timepoint&lt;/P&gt;&lt;P&gt;TX &amp;nbsp; &amp;nbsp; &amp;nbsp; 01 &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;TX &amp;nbsp; &amp;nbsp; &amp;nbsp; 01 &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00FF00"&gt;TX &amp;nbsp; &amp;nbsp; &amp;nbsp; 02 &amp;nbsp; &amp;nbsp; 1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;TX &amp;nbsp; &amp;nbsp; &amp;nbsp; 03 &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;TX &amp;nbsp; &amp;nbsp; &amp;nbsp; 03 &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00FF00"&gt;CT &amp;nbsp; &amp;nbsp; &amp;nbsp; 04 &amp;nbsp; &amp;nbsp; 1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00FF00"&gt;CT &amp;nbsp; &amp;nbsp; &amp;nbsp; 04 &amp;nbsp; &amp;nbsp; 2&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00FF00"&gt;CT &amp;nbsp; &amp;nbsp; &amp;nbsp; 05 &amp;nbsp; &amp;nbsp; 1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Highlight color in green are the rows not be selected.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Reeza has provide me a good way use data; set; But can i do this by proc sql?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Thanks so much for your reply!!!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Chen&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 15:14:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-rows-within-different-groups/m-p/339270#M77402</guid>
      <dc:creator>echoli</dc:creator>
      <dc:date>2017-03-08T15:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: select rows within different groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-rows-within-different-groups/m-p/339271#M77403</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much for your help! It works!!&lt;/P&gt;&lt;P&gt;But can I have other ways, like proc sql, to solve this question?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;Chen&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 15:16:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-rows-within-different-groups/m-p/339271#M77403</guid>
      <dc:creator>echoli</dc:creator>
      <dc:date>2017-03-08T15:16:05Z</dc:date>
    </item>
    <item>
      <title>Re: select rows within different groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-rows-within-different-groups/m-p/339550#M77471</link>
      <description>&lt;P&gt;Sure :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input group :$2.   id    timepoint;
datalines;
TX       01     1
TX       01     2
TX       02     1
TX       03     1
TX       03     2
CT       04     1
CT       04     2
CT       05     1
;

proc sql;
create table want as
select *
from have
where group="TX"
group by group, id
having max(timepoint=1) and max(timepoint=2)
order by group, id, timepoint;
select * from want;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Mar 2017 06:25:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-rows-within-different-groups/m-p/339550#M77471</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-03-09T06:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: select rows within different groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-rows-within-different-groups/m-p/340010#M77654</link>
      <description>&lt;P&gt;Hi PG,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That works!!! thanks so much for your help!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Chen&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 14:55:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-rows-within-different-groups/m-p/340010#M77654</guid>
      <dc:creator>echoli</dc:creator>
      <dc:date>2017-03-10T14:55:35Z</dc:date>
    </item>
  </channel>
</rss>

