<?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: Looping over a dataset to check values in another dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296911#M62294</link>
    <description>&lt;P&gt;Does this overcome the limitation of 256 dataset processing? as it will be fetching counts from same dataset multiple times.&lt;/P&gt;</description>
    <pubDate>Wed, 07 Sep 2016 08:08:39 GMT</pubDate>
    <dc:creator>munitech4u</dc:creator>
    <dc:date>2016-09-07T08:08:39Z</dc:date>
    <item>
      <title>Looping over a dataset to check values in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296753#M62224</link>
      <description>&lt;P&gt;I have a dataset like this:&lt;/P&gt;
&lt;PRE class="lang-py prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="typ"&gt;Primary&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;   col1   col2   
nex1    nex2    nex3    
nex2    nex1    nex3    
nex3    nex1    nex2    &lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want to loop over this dataset for each rowxcol combination and count all cases e.g. where (nex1&amp;gt;=1 and nex2&amp;gt;=1) in another dataset(data_y) which contains these nex1-nex3000 variables. Then move to second case(data_x) where (nex1&amp;gt;=1 and nex3&amp;gt;=1) until the end of row. Now go to the second row of and repeat, til the end of row. So data_x is just to get all the possible cases. I want to get the count for these cases from another dataset data_y&lt;/P&gt;
&lt;P&gt;Data_y is like this:&lt;/P&gt;
&lt;PRE class="lang-py prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="pln"&gt;nex1 nex2 nex3&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.....&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;nex3000
&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;     &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;     &lt;SPAN class="lit"&gt;3&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;     &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;     &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;3&lt;/SPAN&gt;     &lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;     &lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;     &lt;SPAN class="lit"&gt;2&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;     &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;     &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;    &lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;     &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So final dataset will be having counts for these cases(each case from data_x for rowxcol combination):&lt;/P&gt;
&lt;PRE class="lang-py prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="pln"&gt; col1   col2&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;...&lt;/SPAN&gt;
  &lt;SPAN class="lit"&gt;2&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;2&lt;/SPAN&gt;
  &lt;SPAN class="lit"&gt;2&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;
  &lt;SPAN class="lit"&gt;2&lt;/SPAN&gt;      &lt;SPAN class="lit"&gt;1.&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;..&lt;/SPAN&gt;        &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;so pseudo code is like this:&lt;/P&gt;
&lt;PRE class="lang-py prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="kwd"&gt;for&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; each row &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;in&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; data_x&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;:&lt;/SPAN&gt;
     &lt;SPAN class="kwd"&gt;for&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; each col &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;in&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; data_x&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;:&lt;/SPAN&gt;
          &lt;SPAN class="kwd"&gt;if&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;row_val&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;&amp;gt;=&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt; &lt;SPAN class="kwd"&gt;and&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;col_val&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;&amp;gt;=&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt; &lt;SPAN class="kwd"&gt;in&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; data_y&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;:&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;
              select count&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(*)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Sep 2016 16:53:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296753#M62224</guid>
      <dc:creator>munitech4u</dc:creator>
      <dc:date>2016-09-06T16:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: Looping over a dataset to check values in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296769#M62227</link>
      <description>&lt;P&gt;To clarify: The Values you are showing are Varaible Names in another data set?&lt;/P&gt;
&lt;P&gt;Will ANY of the values in your example data set every occur in different columns?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What will the interpretation of the total in Col1 be at the end? You say it is a crosstab. So Cross tab of what?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you better walk us through a much smaller example, say with 5 or 6 variables, show the result desired for each step. You kind of jumped from&amp;nbsp; a "row" result to a cross tab with explaining how to get there. And please provide example data of the result at each step that matches the example data provided for the small example.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2016 15:26:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296769#M62227</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-06T15:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Looping over a dataset to check values in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296771#M62228</link>
      <description>You can use the number part of the variable name as an index into the array of NEX1-NEX3000.</description>
      <pubDate>Tue, 06 Sep 2016 15:31:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296771#M62228</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-09-06T15:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Looping over a dataset to check values in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296772#M62229</link>
      <description>1. yes&lt;BR /&gt;2. Could not understand your question&lt;BR /&gt;&lt;BR /&gt;3. its basically getting all the counts(from data_y) for primaryxcol: cases(looping over each row and col combination in data_x&lt;BR /&gt;&lt;BR /&gt;I updated the question. Let me know, if you need further clarification</description>
      <pubDate>Tue, 06 Sep 2016 15:43:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296772#M62229</guid>
      <dc:creator>munitech4u</dc:creator>
      <dc:date>2016-09-06T15:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: Looping over a dataset to check values in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296780#M62233</link>
      <description>&lt;P&gt;Please provide a small worked example as indicated by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw﻿&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;We do not understand your requirements.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2016 16:51:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296780#M62233</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-06T16:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: Looping over a dataset to check values in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296782#M62235</link>
      <description>I updated the question, now the counts can be produced for final result using data_x and data_y</description>
      <pubDate>Tue, 06 Sep 2016 16:54:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296782#M62235</guid>
      <dc:creator>munitech4u</dc:creator>
      <dc:date>2016-09-06T16:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: Looping over a dataset to check values in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296787#M62239</link>
      <description>&lt;P&gt;How big are your datasets?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2016 17:52:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296787#M62239</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-06T17:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: Looping over a dataset to check values in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296834#M62251</link>
      <description>&lt;P&gt;This example data is why I asked about the duplication of values in different variables:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Primary   col1   col2   
nex1    nex2    nex3    
nex2    nex1    nex3    
nex3    nex1    nex2    &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since nex2 appears in col1 And in col2 that means to get a count of nex2 there will need to be an indicator variable to hold that specific indication. Which will require either&amp;nbsp;creating 3000 indicator variables or something to store which match is which because otherwise I cannot see how you wll combine the counts of col1 matches and col2 matches for the same variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And Having Nex2 in the "primary" isn'tgoing to help much. I believe that given your requirement to match all rows in the first set with the second that you will generate an overcount. For example you second and third row of the the first set will count nex1 twice from row 4 in data_y.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I still cannot figur out what this means in relation to either of the data sets:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;col1   col2...
  2      2
  2      1
  2      1...     &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You are skipping at least one intermediate step a far as I can tell. SHOW the immediate result of the comparisons between&amp;nbsp; dataset 1 and data_y.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2016 20:28:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296834#M62251</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-06T20:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Looping over a dataset to check values in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296867#M62268</link>
      <description>&lt;P&gt;If you want code post a worked example, specifically sample data as a data step, as requested previously. I'm not typing out data. As is, here's my algorithm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Change data_y to a dataset that's 0/1, where 1 is representative of anything greater than 0. Data step using an array would work.&lt;/P&gt;
&lt;P&gt;2. Use Proc Corr to create a distance matrix -&amp;nbsp;&lt;A href="https://gist.github.com/statgeek/a5184a4e1678d81e2643" target="_blank"&gt;https://gist.github.com/statgeek/a5184a4e1678d81e2643&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;3. Transpose output from 2 to a long format, Proc Transpose&lt;/P&gt;
&lt;P&gt;4. Use result from 3 as a lookup to Table 2 via a sql merge. You could transpose data_x to a long and merge to get your results and then transpose back. Or you may be able to do a single sql step depending on how many columns is in data_x. Again you haven't provided the sizes of your dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good Luck.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2016 00:10:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296867#M62268</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-07T00:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: Looping over a dataset to check values in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296882#M62274</link>
      <description>&lt;PRE&gt;
data data_x;
input (Primary   col1   col2) ($);
cards;  
nex1    nex2    nex3    
nex2    nex1    nex3    
nex3    nex1    nex2   
;
run;

data data_y;
input nex1 nex2 nex3;
cards;
1     0    1     
0     0    0     
3     1    0     
1     2    1     
0     0    1   
;
run;
data _null_;
 set data_x end=last;
 if _n_=1 then call execute('proc sql;create table want as');
 call execute(cat('select 
 (select count(*) from data_y where ',Primary,' ge 1 and ',col1,' ge 1) as col1, 
 (select count(*) from data_y where ',Primary,' ge 1 and ',col2,' ge 1) as col2
 from data_y(obs=1)'));
 if last then call execute(';quit;');
  else call execute('union all');
run;

&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Sep 2016 02:07:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296882#M62274</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-09-07T02:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: Looping over a dataset to check values in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296883#M62275</link>
      <description>&lt;PRE&gt;
Here is IML code. I believe it would be very fast.



data data_x;
input (Primary   col1   col2) ($);
cards;  
nex1    nex2    nex3    
nex2    nex1    nex3    
nex3    nex1    nex2   
;
run;

data data_y;
input nex1 nex2 nex3;
cards;
1     0    1     
0     0    0     
3     1    0     
1     2    1     
0     0    1   
;
run;
proc iml;
use data_x nobs nobs_x;
read all var _all_;
close;
use data_y;
read all var _all_;
close;

want=j(nobs_x,2,.);
do i=1 to nobs_x;
 p=value(Primary[i]);
 temp_p=(p &amp;gt;= 1);
 
 c1=value(col1[i]);
 temp_c1=(c1 &amp;gt;= 1);
 want[i,1]=sum((temp_p+temp_c1)=2);

 c2=value(col2[i]);
 temp_c2=(c2 &amp;gt;= 1);
 want[i,2]=sum((temp_p+temp_c2)=2);
 
end;

create want from want;
append from want;
close;  
quit;


&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Sep 2016 02:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296883#M62275</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-09-07T02:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Looping over a dataset to check values in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296899#M62287</link>
      <description>&lt;P&gt;Thanks Xia! But i am having a problem with this, it is throwing the error of maximum limitation of &amp;nbsp;256 tables processing. I think i will have some 1000x9= 9000 such cases. Is there any other method of processing this? Like creating loops of multiple of 256?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2016 05:35:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296899#M62287</guid>
      <dc:creator>munitech4u</dc:creator>
      <dc:date>2016-09-07T05:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: Looping over a dataset to check values in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296903#M62288</link>
      <description>&lt;PRE&gt;
Could you use my IML code ?



data data_x;
input (Primary   col1   col2) ($);
cards;  
nex1    nex2    nex3    
nex2    nex1    nex3    
nex3    nex1    nex2   
;
run;

data data_y;
input nex1 nex2 nex3;
cards;
1     0    1     
0     0    0     
3     1    0     
1     2    1     
0     0    1   
;
run;
data _null_;
 set data_x ;
 call execute(cat('proc sql;create table want_',put(_n_,best.-l),' as select 
 (select count(*) from data_y where ',Primary,' ge 1 and ',col1,' ge 1) as col1, 
 (select count(*) from data_y where ',Primary,' ge 1 and ',col2,' ge 1) as col2
 from data_y(obs=1) quit;'));
run;

data want;
 set want_:;
run;


&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Sep 2016 06:36:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296903#M62288</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-09-07T06:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: Looping over a dataset to check values in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296904#M62289</link>
      <description>&lt;PRE&gt;
Or this code could get you faster.



data data_x;
input (Primary   col1   col2) ($);
cards;  
nex1    nex2    nex3    
nex2    nex1    nex3    
nex3    nex1    nex2   
;
run;

data data_y;
input nex1 nex2 nex3;
cards;
1     0    1     
0     0    0     
3     1    0     
1     2    1     
0     0    1   
;
run;
data _null_;
 set data_x end=last;
 if _n_=1 then call execute('proc sql;');
 call execute(cat('create table want_',put(_n_,best.-l),' as select 
 (select count(*) from data_y where ',Primary,' ge 1 and ',col1,' ge 1) as col1, 
 (select count(*) from data_y where ',Primary,' ge 1 and ',col2,' ge 1) as col2
 from data_y(obs=1);'));
 if last then call execute('quit;');
run;

data want;
 set want_: ;
run;

&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Sep 2016 06:42:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296904#M62289</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-09-07T06:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: Looping over a dataset to check values in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296905#M62290</link>
      <description>&lt;PRE&gt;
I noticed a problem. the order of union data is not right.
Try this one :




data data_x;
input (Primary   col1   col2) ($);
cards;  
nex1    nex2    nex3    
nex2    nex1    nex3    
nex3    nex1    nex2   
nex1    nex2    nex3    
nex2    nex1    nex3    
nex3    nex1    nex2 
nex1    nex2    nex3    
nex2    nex1    nex3    
nex3    nex1    nex2 
nex1    nex2    nex3    
nex2    nex1    nex3    
nex3    nex1    nex2 
;
run;

data data_y;
input nex1 nex2 nex3;
cards;
1     0    1     
0     0    0     
3     1    0     
1     2    1     
0     0    1   
;
run;
data _null_;
 set data_x end=last;
 if _n_=1 then call execute('proc sql;');
 call execute(cat('create table want_',put(_n_,best.-l),' as select 
 (select count(*) from data_y where ',Primary,' ge 1 and ',col1,' ge 1) as col1, 
 (select count(*) from data_y where ',Primary,' ge 1 and ',col2,' ge 1) as col2
 from data_y(obs=1);'));
 if last then do;
  call execute('quit;');
  call symputx('n',_n_);
 end;
run;

data want;
 set want_1-want_&amp;amp;n ;
run;

&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Sep 2016 06:50:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296905#M62290</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-09-07T06:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Looping over a dataset to check values in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296910#M62293</link>
      <description>&lt;P&gt;yes, it seems very fast. It&amp;nbsp;works exactly as wanted. I think i need to get used to proc iml. what could be a good starting point? Thanks for all your efforts!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2016 08:56:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296910#M62293</guid>
      <dc:creator>munitech4u</dc:creator>
      <dc:date>2016-09-07T08:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: Looping over a dataset to check values in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296911#M62294</link>
      <description>&lt;P&gt;Does this overcome the limitation of 256 dataset processing? as it will be fetching counts from same dataset multiple times.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2016 08:08:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/296911#M62294</guid>
      <dc:creator>munitech4u</dc:creator>
      <dc:date>2016-09-07T08:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: Looping over a dataset to check values in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/297141#M62367</link>
      <description>&lt;PRE&gt;
Ha. Here is Rick's blog. You can start with it :


http://blogs.sas.com/content/iml/page/41

&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Sep 2016 10:12:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-over-a-dataset-to-check-values-in-another-dataset/m-p/297141#M62367</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-09-08T10:12:56Z</dc:date>
    </item>
  </channel>
</rss>

