<?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: Observation selection in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/604980#M17153</link>
    <description>&lt;P&gt;Hi &lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3062" target="_self"&gt;&lt;SPAN class="login-bold"&gt;DarthPathos&lt;/SPAN&gt;&lt;/A&gt;,&lt;BR /&gt;Nice to hear from you. Is it possible to send you my dataset privately and discuss exactly what I need with variables exactly as they appear, then we'll publish the solution for the whole SAS community with just the example I've sent.&lt;/P&gt;</description>
    <pubDate>Mon, 18 Nov 2019 13:07:49 GMT</pubDate>
    <dc:creator>soumri</dc:creator>
    <dc:date>2019-11-18T13:07:49Z</dc:date>
    <item>
      <title>Observation selection</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/604448#M17061</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;It's a somewhat complicated question I'm going to ask here, but many of my analyzes depend heavily on it. Your help would be, therefore, very precious for me.&lt;/P&gt;&lt;P&gt;In fact, I have a database with over than 700,000 observations, that seems to this:&lt;/P&gt;&lt;P&gt;GROUP ID&amp;nbsp; &amp;nbsp; &amp;nbsp; RANK&amp;nbsp; TD&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; YEAR SEASON GYS&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Value&lt;BR /&gt;LH84&amp;nbsp;&amp;nbsp;B000001&amp;nbsp;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;28MAR2011&amp;nbsp;2011&amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; LH8420111 11.2&lt;BR /&gt;LH84&amp;nbsp;&amp;nbsp;B000001&amp;nbsp;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;30MAY2011&amp;nbsp;2011&amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; LH8420111&amp;nbsp; 9.6&lt;BR /&gt;LH84&amp;nbsp;&amp;nbsp;B000001&amp;nbsp;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;27JUN2011&amp;nbsp;2011&amp;nbsp;3&amp;nbsp; &amp;nbsp; &amp;nbsp; LH8420113&amp;nbsp; 7.8&lt;BR /&gt;LH84&amp;nbsp;&amp;nbsp;B000001&amp;nbsp;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;01AUG2011&amp;nbsp;2011&amp;nbsp;3&amp;nbsp; &amp;nbsp; &amp;nbsp; LH8420113&amp;nbsp; 7.2&lt;BR /&gt;LH84&amp;nbsp;&amp;nbsp;B000001&amp;nbsp;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;09FEB2012&amp;nbsp;2012&amp;nbsp;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;LH8420121 19.3&lt;BR /&gt;LH84&amp;nbsp;&amp;nbsp;B000001&amp;nbsp;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;10APR2012&amp;nbsp;2012&amp;nbsp;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;LH8420122 20.6&lt;BR /&gt;LH84&amp;nbsp;&amp;nbsp;B000002&amp;nbsp;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;10APR2012&amp;nbsp;2012&amp;nbsp;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;LH8420122&amp;nbsp; 9.4&lt;BR /&gt;LH84&amp;nbsp;&amp;nbsp;B000002&amp;nbsp;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;05JUN2012&amp;nbsp;2012&amp;nbsp;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;LH8420123 10.9&lt;BR /&gt;LH84&amp;nbsp; B000002 1&amp;nbsp; &amp;nbsp; &amp;nbsp;14AUG2012 2012 3&amp;nbsp; &amp;nbsp; &amp;nbsp; LH8420123&amp;nbsp; 8.7&lt;BR /&gt;KC01&amp;nbsp; B000013 4&amp;nbsp; &amp;nbsp; &amp;nbsp;18JUN2000 2000 3&amp;nbsp; &amp;nbsp; &amp;nbsp; KC0120003&amp;nbsp; 9.6&lt;BR /&gt;KC01&amp;nbsp; B000013 4&amp;nbsp; &amp;nbsp; &amp;nbsp;14AUG2000 2000 3&amp;nbsp; &amp;nbsp; &amp;nbsp; KC0120003&amp;nbsp; 9.2&lt;BR /&gt;KC01&amp;nbsp; B000013 4&amp;nbsp; &amp;nbsp; &amp;nbsp;14OCT2000 2000 4&amp;nbsp; &amp;nbsp; &amp;nbsp; KC0120004&amp;nbsp; 7.2&lt;BR /&gt;etc...&lt;/P&gt;&lt;P&gt;With:&lt;/P&gt;&lt;P&gt;- TD is a test date,&lt;/P&gt;&lt;P&gt;- Year is the year of TD (extracted from the TD variable)&lt;/P&gt;&lt;P&gt;- Season is the season of the TD (Months from the test date were used to create the season variable).&lt;/P&gt;&lt;P&gt;- And,&amp;nbsp;&lt;STRONG&gt;GYS&lt;/STRONG&gt; is a composite variable, created from &lt;STRONG&gt;G&lt;/STRONG&gt;ROUP, &lt;STRONG&gt;Y&lt;/STRONG&gt;EAR and &lt;STRONG&gt;S&lt;/STRONG&gt;EASON variables&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* In my raw database there are almost 1100 different GROUPS, more than 45,000 different IDs, 5 different RANK, 15 Years (from 2000 to 2014) and 4 SEASONS.&lt;/P&gt;&lt;P&gt;* Each ID can have up to 11 different tests for a particular RANK&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I to create another new one (while keeping the same variables), which fulfills the following conditions?&lt;/P&gt;&lt;P&gt;- Only &lt;STRONG&gt;IDs&lt;/STRONG&gt; with &lt;U&gt;&lt;STRONG&gt;at least 3 tests&lt;/STRONG&gt;&lt;/U&gt; &lt;STRONG&gt;for a particular RANK&amp;nbsp;&lt;/STRONG&gt;are considered.&lt;BR /&gt;- Only &lt;STRONG&gt;GROUPS&lt;/STRONG&gt; that contain &lt;STRONG&gt;at least 5 &lt;U&gt;different IDs&lt;/U&gt;&lt;/STRONG&gt;&lt;U&gt; &lt;STRONG&gt;in a given YEAR&lt;/STRONG&gt;&lt;/U&gt; are considered;&lt;BR /&gt;- For each class of &lt;STRONG&gt;GYS&lt;/STRONG&gt; there are&amp;nbsp;&lt;STRONG&gt;at least 4 observations&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;The sample I gave is very small and can not be used to test any code, but I could provide you with a larger sample if the need arises.&lt;BR /&gt;My best thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 13:17:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/604448#M17061</guid>
      <dc:creator>soumri</dc:creator>
      <dc:date>2019-11-15T13:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: Observation selection</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/604452#M17064</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/87866"&gt;@soumri&lt;/a&gt; -&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without actually testing this I think the easiest would be to run a couple of PROC SQL queries that would generate tables and then update your dataset accordingly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 21.33px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;- Only &lt;/SPAN&gt;&lt;STRONG style="background-color: transparent; box-sizing: border-box; color: #333333; font-family: &amp;amp;quot; helevticaneue-light&amp;amp;quot;,&amp;amp;quot;helvetica neue&amp;amp;quot;,helvetica,arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: bold; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;IDs&lt;/STRONG&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 21.33px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt; with &lt;/SPAN&gt;&lt;U style="background-color: transparent; box-sizing: border-box; color: #333333; font-family: &amp;amp;quot; helevticaneue-light&amp;amp;quot;,&amp;amp;quot;helvetica neue&amp;amp;quot;,helvetica,arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: underline; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;&lt;STRONG style="box-sizing: border-box; font-style: normal; font-weight: bold;"&gt;at least 3 tests&lt;/STRONG&gt;&lt;/U&gt; &lt;STRONG style="background-color: transparent; box-sizing: border-box; color: #333333; font-family: &amp;amp;quot; helevticaneue-light&amp;amp;quot;,&amp;amp;quot;helvetica neue&amp;amp;quot;,helvetica,arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: bold; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;for a particular RANK&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 21.33px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;are considered.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;&lt;BR /&gt;create table id_count as 
select ID, count(test_variable) as Cnt
from table_name
where rank = "1"
group by ID
order by ID;
QUIT:&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 21.33px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;- Only &lt;/SPAN&gt;&lt;STRONG style="background-color: transparent; box-sizing: border-box; color: #333333; font-family: &amp;amp;quot; helevticaneue-light&amp;amp;quot;,&amp;amp;quot;helvetica neue&amp;amp;quot;,helvetica,arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: bold; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;GROUPS&lt;/STRONG&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 21.33px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt; that contain &lt;/SPAN&gt;&lt;STRONG style="background-color: transparent; box-sizing: border-box; color: #333333; font-family: &amp;amp;quot; helevticaneue-light&amp;amp;quot;,&amp;amp;quot;helvetica neue&amp;amp;quot;,helvetica,arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: bold; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;at least 5 &lt;U style="box-sizing: border-box;"&gt;different IDs&lt;/U&gt;&lt;/STRONG&gt;&lt;U style="background-color: transparent; box-sizing: border-box; color: #333333; font-family: &amp;amp;quot; helevticaneue-light&amp;amp;quot;,&amp;amp;quot;helvetica neue&amp;amp;quot;,helvetica,arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: underline; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt; &lt;STRONG style="box-sizing: border-box; font-style: normal; font-weight: bold;"&gt;in a given YEAR&lt;/STRONG&gt;&lt;/U&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 21.33px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt; are considered;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
select distinct group, ID, year
into #Temp_Table
from table_name;
&lt;BR /&gt;create table grp_cnt as
select group, year, count(*) as Cnt
from #Temp_Table
group by group, year
having count(*)&amp;gt;=5
order by group, year; 
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 21.33px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;- For each class of &lt;/SPAN&gt;&lt;STRONG style="background-color: transparent; box-sizing: border-box; color: #333333; font-family: &amp;amp;quot; helevticaneue-light&amp;amp;quot;,&amp;amp;quot;helvetica neue&amp;amp;quot;,helvetica,arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: bold; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;GYS&lt;/STRONG&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 21.33px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt; there are&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG style="background-color: transparent; box-sizing: border-box; color: #333333; font-family: &amp;amp;quot; helevticaneue-light&amp;amp;quot;,&amp;amp;quot;helvetica neue&amp;amp;quot;,helvetica,arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: bold; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;at least 4 observations&lt;/STRONG&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 21.33px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 
PROC SQL;
select distinct gys, ID
into #Temp_Table2
from table_name
group by gys, ID
order by gys, ID;
&lt;BR /&gt;create table gys_cnt as  
select gys, count(*) as Cnt
from #Temp_Table2 
group by gys
having count(*)&amp;gt;=4
order by gys;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You should be able to then take the results from your tables and generate new variables etc. as needed (select a.* , b.* from main_table a left join gys_cnt b on a.id = b.id or something similar).&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;
&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 13:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/604452#M17064</guid>
      <dc:creator>DarthPathos</dc:creator>
      <dc:date>2019-11-15T13:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Observation selection</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/604469#M17066</link>
      <description>&lt;P&gt;Thank you for paying attention to my request.&lt;/P&gt;&lt;P&gt;I see that the first part of the code ( just a counter, which I have already tried), should be changed by this one:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
create table id_count as
select ID, count (test_variable) as Cnt
from table_name
group by ID, rank
order by ID, Rank, TD;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;for the second and third condition, they must not be separated to accomplish them together. Treating them separately leads to false results.&lt;BR /&gt;moreover, for the second condition, an error is generated which I do not see where is the problem:&lt;/P&gt;&lt;P&gt;16558 select distinct group, ID, year into Temp_Table&lt;BR /&gt;&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; &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; -------&lt;BR /&gt;&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; &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; 79&lt;BR /&gt;ERROR 79-322: Expecting a:.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 14:27:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/604469#M17066</guid>
      <dc:creator>soumri</dc:creator>
      <dc:date>2019-11-15T14:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: Observation selection</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/604476#M17070</link>
      <description>&lt;P&gt;Hm - OK, I don't have access to SAS right now but I will try to take a closer look when I'm home later today.&amp;nbsp; In the meantime, take a look at the following links as they may help:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/General-SAS-Programming/Creating-a-conditional-Variable/td-p/295677" target="_blank"&gt;https://communities.sas.com/t5/General-SAS-Programming/Creating-a-conditional-Variable/td-p/295677&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/creating-and-recoding-variables-in-sas/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/creating-and-recoding-variables-in-sas/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Creating-a-conditional-count-variable/td-p/181598" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Creating-a-conditional-count-variable/td-p/181598&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck and post back if you figure anything out, or if you have additional questions &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 14:34:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/604476#M17070</guid>
      <dc:creator>DarthPathos</dc:creator>
      <dc:date>2019-11-15T14:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Observation selection</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/604484#M17076</link>
      <description>&lt;P&gt;thank you&amp;nbsp;&lt;SPAN class="login-bold"&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3062" target="_self"&gt;DarthPathos&lt;/A&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;I could perhaps send you my dataset with the real variables, if tests are needed.&lt;BR /&gt;A colleague told me (because it sounds like a loop maybe) that I have to use ARRAYs and DO Loops !!!! I do not know!&lt;BR /&gt;I will remain at your disposal for more details.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 14:44:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/604484#M17076</guid>
      <dc:creator>soumri</dc:creator>
      <dc:date>2019-11-15T14:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: Observation selection</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/604485#M17077</link>
      <description>&lt;P&gt;Arrays and DO Loops are extremely powerful...and really confusing if you've never used them.&amp;nbsp; I'll see what I can do tonight / this weekend and will post back, maybe a subset of the live data will help but I'll let you know. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 14:49:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/604485#M17077</guid>
      <dc:creator>DarthPathos</dc:creator>
      <dc:date>2019-11-15T14:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: Observation selection</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/604973#M17151</link>
      <description>&lt;P&gt;Good morning&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/87866"&gt;@soumri&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've done some tests on some dummy data I created based on your original post.&amp;nbsp; I think I have something figured out but if you can post your dataset, that would be fantastic - I don't want to post anything here that won't help you.&amp;nbsp; Once I've had a chance to run through your dataset, I'll be able to confirm my code and will then post back here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'll need a day or two after you send me the data; hopefully that's OK.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 12:50:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/604973#M17151</guid>
      <dc:creator>DarthPathos</dc:creator>
      <dc:date>2019-11-18T12:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Observation selection</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/604980#M17153</link>
      <description>&lt;P&gt;Hi &lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3062" target="_self"&gt;&lt;SPAN class="login-bold"&gt;DarthPathos&lt;/SPAN&gt;&lt;/A&gt;,&lt;BR /&gt;Nice to hear from you. Is it possible to send you my dataset privately and discuss exactly what I need with variables exactly as they appear, then we'll publish the solution for the whole SAS community with just the example I've sent.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 13:07:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/604980#M17153</guid>
      <dc:creator>soumri</dc:creator>
      <dc:date>2019-11-18T13:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: Observation selection</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/604983#M17154</link>
      <description>&lt;P&gt;If you can enable Private Messages in your SAS Communities profile, I will message you with my email address.&lt;/P&gt;
&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 13:10:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/604983#M17154</guid>
      <dc:creator>DarthPathos</dc:creator>
      <dc:date>2019-11-18T13:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: Observation selection</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/607681#M17584</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/87866"&gt;@soumri&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's not elegant, but it works (as we've discussed over email).&amp;nbsp; This is more step-by-step than I would normally do it but I did it this way intentionally so that you (and others) would understand what I was doing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking forward to seeing your paper!&amp;nbsp; Please reach out should you need anything further.&lt;BR /&gt;Chris&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* 
Code written and tested on SAS University Edition, running on a MacBook Pro and VirtualBox.  &lt;BR /&gt;SAS UE is run on Chrome.&lt;BR /&gt;&lt;BR /&gt;Requirements:
1) A minimum of 4 and a maximum of 11 observations for each identifier in a given rank (already verified) AND
2) Each group (GRP) for a given YTD must contain at least 5 different IDs. AND
3) Each class of GYS must contain at least 4 observations.

Description of the code:
1 - 3: Take the requirements above and create specific temporary tables with the data that meet the criteria
4: Take the temp table that I have created in 1 and create a new table where the IDs from Table1
   match those in our original table
5: Take the new table created in 4 and match it with the original data by GRP and YTD
6: Take the new table created in 5 and match it with the original data by ID

Results:
This ends up with a dataset (n = 525) that match all three of your criteria.&lt;BR /&gt;&lt;BR /&gt;Addition: Step 7 - Remerged the 525 observations back with the original dataset and create a &lt;BR /&gt;flag to indicate a match.

Notes: Change "work.import" to whatever library.table_name you have.  Once you've made that change, 
  the remainder of the code should work.  I've tested this three times and get the same results.
*/

/* Import code 
%web_drop_table(WORK.IMPORT);
FILENAME REFFILE '/folders/myfolders/dataset.csv';
PROC IMPORT DATAFILE=REFFILE
	DBMS=CSV
	OUT=WORK.IMPORT;
	GETNAMES=YES;
RUN;
PROC CONTENTS DATA=WORK.IMPORT; RUN;
%web_open_table(WORK.IMPORT);
*/

proc sql; 
/* 1 */ 
create table work.table1 as 
select ID, count(*) as Cnt
from work.import
group by ID
having count(*)&amp;gt;=4 and count(*)&amp;lt;=11
order by ID;

/* 2 */
create table work.table2a as 
select distinct grp, ytd, id
from work.import;

create table work.table2 as
select grp, ytd, count(*) as Cnt 
from work.table2a
group by grp, ytd
having count(*)&amp;gt;=5
order by grp, ytd;

/* 3 */
create table work.table3 as 
select gys, count(*) as Cnt
from work.import
group by gys
having count(*)&amp;gt;=4
order by gys;

/* 4 */
create table work.table5 as 
select a.* 
from work.import a, work.table3 b 
where a.gys = b.gys;

/* 5 */
create table work.table6 as 
select a.*
from work.import a, work.table2 b
where a.grp = b.grp
and a.ytd = b.ytd;

/* 6 */
create table work.table7 as 
select a.*
from work.import a, work.table1 b
where a.id = b.id;
quit;

/* 7 */
proc sql;
create table work.final as 
select a.*, 
case when b.id is not null then '1' else '0' end as Match
from work.import a left join work.table7 b  
/* LEFT Join = ALL records from the original table and the records that match from TABLE7 */
 on a.grp = b.grp
 and a.gys = b.gys 
 and a.id = b.id;
 
 select * from work.final order by Match desc;
 quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 13:54:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/607681#M17584</guid>
      <dc:creator>DarthPathos</dc:creator>
      <dc:date>2019-11-27T13:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: Observation selection</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/608025#M17611</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3062"&gt;@DarthPathos&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes Chris, it works very well. Thank you for this valuable collaboration.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Nov 2019 10:53:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Observation-selection/m-p/608025#M17611</guid>
      <dc:creator>soumri</dc:creator>
      <dc:date>2019-11-28T10:53:45Z</dc:date>
    </item>
  </channel>
</rss>

