<?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: Two types of records; two selection rules. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Two-types-of-records-two-selection-rules/m-p/52045#M10970</link>
    <description>That's what I have done.&lt;BR /&gt;
&lt;BR /&gt;
Anyone(but not both) of the data sets could then be empty after splitting the original data set.&lt;BR /&gt;
&lt;BR /&gt;
The program was supposed to be used by other persons with new data periodically and the program should be general.&lt;BR /&gt;
&lt;BR /&gt;
 I didn't think it was possble to join a non-empty set with an empty set. That was the problem for me. But I have now found out that code like this works:&lt;BR /&gt;
&lt;BR /&gt;
data joined_data;&lt;BR /&gt;
set non_emptyset emptyset;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I should have checked before I asked the forum.&lt;BR /&gt;
&lt;BR /&gt;
Thank's.</description>
    <pubDate>Sun, 19 Dec 2010 19:16:20 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-12-19T19:16:20Z</dc:date>
    <item>
      <title>Two types of records; two selection rules.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-types-of-records-two-selection-rules/m-p/52041#M10966</link>
      <description>ID_ X_Var1_Var2 ...&lt;BR /&gt;
1 _0&lt;BR /&gt;
1_1&lt;BR /&gt;
2_0&lt;BR /&gt;
2_0&lt;BR /&gt;
2_0&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
For each ID, one and only one record should be kept. When there is at least one record with X=1 one selection rule applies. When X=0 in every record another selection rule applies. (The different selection rules use the other variables; Var1, Var2, ..., in different ways.)&lt;BR /&gt;
&lt;BR /&gt;
There could be situations when the data set contains only one type of records, so I can't split the the data into two sets and use the different rules for each set, and then join them. &lt;BR /&gt;
&lt;BR /&gt;
The program should be general.&lt;BR /&gt;
&lt;BR /&gt;
Any idea on how to solve this, would be much appreciated.</description>
      <pubDate>Sat, 18 Dec 2010 22:58:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-types-of-records-two-selection-rules/m-p/52041#M10966</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-12-18T22:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: Two types of records; two selection rules.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-types-of-records-two-selection-rules/m-p/52042#M10967</link>
      <description>Using PROC MEANS/SUMMARY, build a file with MAX(X) BY ID, then MERGE that file back onto the (sorted) original file so you can detect the "at least one" X=1 condition, then use IF / THEN logic to perform the conditional logic.  As suggested before, break down your overall "task" into individual requirements, program for each, then combine into a single SAS program.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Sat, 18 Dec 2010 23:20:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-types-of-records-two-selection-rules/m-p/52042#M10967</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-12-18T23:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Two types of records; two selection rules.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-types-of-records-two-selection-rules/m-p/52043#M10968</link>
      <description>When there was an ID with at least one record with X=1 then a sorting could be done BY ID VAR1 VAR2 and VAR3, and I could use the condition &lt;BR /&gt;
&lt;BR /&gt;
IF LAST.ID;&lt;BR /&gt;
&lt;BR /&gt;
to select the right record.&lt;BR /&gt;
&lt;BR /&gt;
When all records have X=0, the sorting should be done BY ID VAR4 and VAR5, and the condition would again be&lt;BR /&gt;
&lt;BR /&gt;
IF LAST.ID;&lt;BR /&gt;
&lt;BR /&gt;
I don't understand your suggestion.</description>
      <pubDate>Sat, 18 Dec 2010 23:38:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-types-of-records-two-selection-rules/m-p/52043#M10968</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-12-18T23:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: Two types of records; two selection rules.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-types-of-records-two-selection-rules/m-p/52044#M10969</link>
      <description>Ernesto,&lt;BR /&gt;
&lt;BR /&gt;
If the values of X are only 1 and 0, then why not approach it differently.  If you sort you data by id and descending X, then you could use a simple data step to separate the records into two groups.  e.g.:&lt;BR /&gt;
&lt;BR /&gt;
data atleastone1 (drop=group) allzeros (drop=group);&lt;BR /&gt;
  set have;&lt;BR /&gt;
  by id;&lt;BR /&gt;
  retain group;&lt;BR /&gt;
  if first.id then do;&lt;BR /&gt;
    if x eq 1 then group=1;&lt;BR /&gt;
    else group=0;&lt;BR /&gt;
  end;&lt;BR /&gt;
  if group eq 1 then output atleastone1;&lt;BR /&gt;
  else output allzeros;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Then you will have two different datasets that you can sort and analyze as you describe.&lt;BR /&gt;
&lt;BR /&gt;
Art</description>
      <pubDate>Sun, 19 Dec 2010 15:02:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-types-of-records-two-selection-rules/m-p/52044#M10969</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2010-12-19T15:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: Two types of records; two selection rules.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-types-of-records-two-selection-rules/m-p/52045#M10970</link>
      <description>That's what I have done.&lt;BR /&gt;
&lt;BR /&gt;
Anyone(but not both) of the data sets could then be empty after splitting the original data set.&lt;BR /&gt;
&lt;BR /&gt;
The program was supposed to be used by other persons with new data periodically and the program should be general.&lt;BR /&gt;
&lt;BR /&gt;
 I didn't think it was possble to join a non-empty set with an empty set. That was the problem for me. But I have now found out that code like this works:&lt;BR /&gt;
&lt;BR /&gt;
data joined_data;&lt;BR /&gt;
set non_emptyset emptyset;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I should have checked before I asked the forum.&lt;BR /&gt;
&lt;BR /&gt;
Thank's.</description>
      <pubDate>Sun, 19 Dec 2010 19:16:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-types-of-records-two-selection-rules/m-p/52045#M10970</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-12-19T19:16:20Z</dc:date>
    </item>
  </channel>
</rss>

