<?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: Working out data set based on rule scoring in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Working-out-data-set-based-on-rule-scoring/m-p/546109#M8164</link>
    <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;has demonstrated, it's easy enough for a computer to calculate all the possibilities.&amp;nbsp; While I disagree with his choice of variable names (ruleshit), here is what might be a simpler way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data combos;&lt;/P&gt;
&lt;P&gt;array rule {16};&lt;/P&gt;
&lt;P&gt;do rule1=0, -32768;&lt;/P&gt;
&lt;P&gt;do rule2=0, -16384;&lt;/P&gt;
&lt;P&gt;do rule3=0, -8192;&lt;/P&gt;
&lt;P&gt;do rule4=0, -4096;&lt;/P&gt;
&lt;P&gt;do rule5=0, -2048;&lt;/P&gt;
&lt;P&gt;do rule6=0, -1024;&lt;/P&gt;
&lt;P&gt;do rule7=0, -512;&lt;/P&gt;
&lt;P&gt;do rule8=0, -256;&lt;/P&gt;
&lt;P&gt;do rule9=0, -128;&lt;/P&gt;
&lt;P&gt;do rule10=0, -64;&lt;/P&gt;
&lt;P&gt;do rule11=0, -32;&lt;/P&gt;
&lt;P&gt;do rule12=0, -16;&lt;/P&gt;
&lt;P&gt;do rule13=0, -8;&lt;/P&gt;
&lt;P&gt;do rule14=0, -4;&lt;/P&gt;
&lt;P&gt;do rule15=0, -2;&lt;/P&gt;
&lt;P&gt;do rule16=0, -1;&lt;/P&gt;
&lt;P&gt;total = sum(of rule1-rule16);&lt;/P&gt;
&lt;P&gt;length rules_hit $ 40;&lt;/P&gt;
&lt;P&gt;rules_hit = ' ';&lt;/P&gt;
&lt;P&gt;do k=1 to 16;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if rule{k} ne 0 then rules_hit = catx(',' , rules_hit, k);&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;end; end; end; end; end;&lt;/P&gt;
&lt;P&gt;end; end; end; end; end;&lt;/P&gt;
&lt;P&gt;end; end; end; end; end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;keep total rules_hit;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This allows you to sort and merge with your scores (or perhaps some other form of look-up).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Mar 2019 13:00:30 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2019-03-26T13:00:30Z</dc:date>
    <item>
      <title>Working out data set based on rule scoring</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Working-out-data-set-based-on-rule-scoring/m-p/546071#M8153</link>
      <description>&lt;P&gt;Hi - please bear with me here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a 3rd party data source that provides us data based on specific conditions an order has hit. We do not know which conditions were hit so cannot analyse any data. Within the data, we do get a score set and i have managed to give each condition its own score based on bits:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Rule&lt;/TD&gt;&lt;TD&gt;Weight&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;-32768&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt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p;&lt;/P&gt;&lt;P&gt;The idea is, that if the score is -580, there are only 3 rules it could possibly be (7,10,14), or -65535 it would have hit all 16 - so we can then know which rules were hit.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is: Is there a way of coding into sas a way to work out which rules were hit? Working it out manually for each score would take an age.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope i have explained myself? Any help is much appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2019 11:42:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Working-out-data-set-based-on-rule-scoring/m-p/546071#M8153</guid>
      <dc:creator>MattehWoo</dc:creator>
      <dc:date>2019-03-26T11:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: Working out data set based on rule scoring</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Working-out-data-set-based-on-rule-scoring/m-p/546083#M8159</link>
      <description>&lt;P&gt;For me, it would be logical that rules 7 (-512),10 (-64) and 14 (-4) were hit as those sum up to -580.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2019 11:40:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Working-out-data-set-based-on-rule-scoring/m-p/546083#M8159</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-03-26T11:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: Working out data set based on rule scoring</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Working-out-data-set-based-on-rule-scoring/m-p/546084#M8160</link>
      <description>Correct - i was looking at the wrong numbers!</description>
      <pubDate>Tue, 26 Mar 2019 11:41:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Working-out-data-set-based-on-rule-scoring/m-p/546084#M8160</guid>
      <dc:creator>MattehWoo</dc:creator>
      <dc:date>2019-03-26T11:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: Working out data set based on rule scoring</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Working-out-data-set-based-on-rule-scoring/m-p/546089#M8161</link>
      <description>&lt;P&gt;See my take:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data rules;
infile datalines dlm='09'x dsd;
input rulenumber rulevalue;
datalines;
1	-32768
2	-16384
3	-8192
4	-4096
5	-2048
6	-1024
7	-512
8	-256
9	-128
10	-64
11	-32
12	-16
13	-8
14	-4
15	-2
16	-1
;
run;

data have;
input value;
datalines;
-580
;
run;

data want;
if _n_ = 1
then do;
  array rules {16} _temporary_;
  do i = 1 to 16;
    set rules;
    rules{i} = rulevalue;
  end;
end;
set have;
_val = value;
length rules_hit $100;
do i = 1 to dim(rules);
  put _val=;
  put rules{i}=;
  if _val &amp;lt;= rules{i}
  then do;
    rules_hit = catx(',',rules_hit,put(i,2.));
    _val = _val - rules{i};
  end;
end;
keep value rules_hit;
run;
    
proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;value    rules_hit

 -580    7,10,14 
&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Mar 2019 12:57:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Working-out-data-set-based-on-rule-scoring/m-p/546089#M8161</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-03-26T12:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: Working out data set based on rule scoring</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Working-out-data-set-based-on-rule-scoring/m-p/546109#M8164</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;has demonstrated, it's easy enough for a computer to calculate all the possibilities.&amp;nbsp; While I disagree with his choice of variable names (ruleshit), here is what might be a simpler way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data combos;&lt;/P&gt;
&lt;P&gt;array rule {16};&lt;/P&gt;
&lt;P&gt;do rule1=0, -32768;&lt;/P&gt;
&lt;P&gt;do rule2=0, -16384;&lt;/P&gt;
&lt;P&gt;do rule3=0, -8192;&lt;/P&gt;
&lt;P&gt;do rule4=0, -4096;&lt;/P&gt;
&lt;P&gt;do rule5=0, -2048;&lt;/P&gt;
&lt;P&gt;do rule6=0, -1024;&lt;/P&gt;
&lt;P&gt;do rule7=0, -512;&lt;/P&gt;
&lt;P&gt;do rule8=0, -256;&lt;/P&gt;
&lt;P&gt;do rule9=0, -128;&lt;/P&gt;
&lt;P&gt;do rule10=0, -64;&lt;/P&gt;
&lt;P&gt;do rule11=0, -32;&lt;/P&gt;
&lt;P&gt;do rule12=0, -16;&lt;/P&gt;
&lt;P&gt;do rule13=0, -8;&lt;/P&gt;
&lt;P&gt;do rule14=0, -4;&lt;/P&gt;
&lt;P&gt;do rule15=0, -2;&lt;/P&gt;
&lt;P&gt;do rule16=0, -1;&lt;/P&gt;
&lt;P&gt;total = sum(of rule1-rule16);&lt;/P&gt;
&lt;P&gt;length rules_hit $ 40;&lt;/P&gt;
&lt;P&gt;rules_hit = ' ';&lt;/P&gt;
&lt;P&gt;do k=1 to 16;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if rule{k} ne 0 then rules_hit = catx(',' , rules_hit, k);&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;end; end; end; end; end;&lt;/P&gt;
&lt;P&gt;end; end; end; end; end;&lt;/P&gt;
&lt;P&gt;end; end; end; end; end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;keep total rules_hit;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This allows you to sort and merge with your scores (or perhaps some other form of look-up).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2019 13:00:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Working-out-data-set-based-on-rule-scoring/m-p/546109#M8164</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-03-26T13:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: Working out data set based on rule scoring</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Working-out-data-set-based-on-rule-scoring/m-p/546112#M8166</link>
      <description>&lt;P&gt;OMG!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Well, that's what can come from not being a native speaker. Corrected it.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2019 12:58:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Working-out-data-set-based-on-rule-scoring/m-p/546112#M8166</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-03-26T12:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: Working out data set based on rule scoring</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Working-out-data-set-based-on-rule-scoring/m-p/546151#M8172</link>
      <description>&lt;P&gt;You can easily extract the rule numbers by examining the bit string of the positive value of value.&amp;nbsp; Here I do it as a 16 byte character variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   input value;
   bitvalue = put(-value,binary16.);
   f=findc(bitvalue,'1',1);
   length ruleshit $64;
   do while(f);
      ruleshit = catx(', ',ruleshit,f);
      f = f + 1;
      f=findc(bitvalue,'1',f);
      end;
   drop f;
   datalines;
-580
-321
-0
-512
-65535
;;;;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 523px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/28218i1305025B471EC5B7/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2019 14:03:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Working-out-data-set-based-on-rule-scoring/m-p/546151#M8172</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2019-03-26T14:03:13Z</dc:date>
    </item>
  </channel>
</rss>

