<?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: More efficient way of proc sql joining ON a disjunction in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287829#M59260</link>
    <description>&lt;P&gt;Yes, there was something odd when I copied out from the test data you gave to my environment, it shows a square between some of the data. &amp;nbsp;Must be the different system encodings. &amp;nbsp;Anyways, if you take your original test data, and copy from below the datalines to the ;;;; and replace that in the code you run, it should be fine. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could be something wierd with the website too. &amp;nbsp;This is what I see when I copy your test data to my system:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/4306iDE4653E3B9CB0F62/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Jul 2016 14:53:41 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-07-28T14:53:41Z</dc:date>
    <item>
      <title>More efficient way of proc sql joining ON a disjunction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287742#M59238</link>
      <description>&lt;P&gt;SAS Enterprise Guide 5.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two similar data sets, say Table1 and Table2&amp;nbsp;(basically they &lt;STRONG&gt;structurally&lt;/STRONG&gt;&amp;nbsp;are the same&amp;nbsp;data set similar variables&amp;nbsp;(with different cell values)&amp;nbsp;regarding different periods), with 64 columns and approximately 550K rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to do the following.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;                  PROC SQL;
                  CREATE TABLE JOINED TABLE AS
                  SELECT Some variables
                  FROM Table1 T1
                  LEFT JOIN Table2 T2 ON ((T1.Var1=T2.Var1 AND T1.Var2=T2.Var2) OR T1.Var1=T2.Var2);
                  QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it's just too slow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a (much) more efficient way of achieving the same result?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's an example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Data201606;
    LENGTH
        Var1             $ 14
        Var2             $ 14
        WholeBunchOfVars_201606 $ 24 ;
    FORMAT
        Var1             $CHAR14.
        Var2             $CHAR14.
        WholeBunchOfVars_201606 $CHAR24. ;
    INFORMAT
        Var1             $CHAR14.
        Var2             $CHAR14.
        WholeBunchOfVars_201606 $CHAR24. ;
    INFILE DATALINES4
        DLM='7F'x
        MISSOVER
        DSD ;
    INPUT
        Var1             : $CHAR14.
        Var2             : $CHAR14.
        WholeBunchOfVars_201606 : $CHAR24. ;
DATALINES4;
42001223829005&amp;#127;42001223821100&amp;#127;1913672811803603960
42001223829005&amp;#127;42001223829100&amp;#127;1913672811803603960
42001223829005&amp;#127;42001223822100&amp;#127;1913672811803603960
42005537849003&amp;#127;42005537841100&amp;#127;1728228741505881940
42000000420200&amp;#127; &amp;#127;149282958163677760150000
42000001251100&amp;#127; &amp;#127;137224761123272858132500
42000002571100&amp;#127; &amp;#127;115006036153103523280000
42000002992100&amp;#127; &amp;#127;176705643184314704200000
42000003721100&amp;#127; &amp;#127;134284160134284151225000
;;;;

DATA Data201607;
    LENGTH
        Var1             $ 14
        Var2             $ 14
        WholeBunchOfVars_201607 $ 24 ;
    FORMAT
        Var1             $CHAR14.
        Var2             $CHAR14.
        WholeBunchOfVars_201607 $CHAR24. ;
    INFORMAT
        Var1             $CHAR14.
        Var2             $CHAR14.
        WholeBunchOfVars_201607 $CHAR24. ;
    INFILE DATALINES4
        DLM='7F'x
        MISSOVER
        DSD ;
    INPUT
        Var1             : $CHAR14.
        Var2             : $CHAR14.
        WholeBunchOfVars_201607 : $CHAR24. ;
DATALINES4;
42001223829005&amp;#127;42001223822100&amp;#127;1913672811803603960
42001223829005&amp;#127;42001223821100&amp;#127;1913672811803603960
42001223829005&amp;#127;42001223829100&amp;#127;1913672811803603960
48073274008100&amp;#127;.&amp;#127;..50000
48077274928100&amp;#127;.&amp;#127;..150000
48120011318100&amp;#127;.&amp;#127;..200000
48097297288100&amp;#127;.&amp;#127;..200000
48001314298100&amp;#127;.&amp;#127;..250000
48035295388100&amp;#127;.&amp;#127;..575000
48089429268100&amp;#127;.&amp;#127;..600000
48001012248100&amp;#127;.&amp;#127;..600000
48075642348100&amp;#127;.&amp;#127;..700000
42026909980100&amp;#127;.&amp;#127;000000000.25000
42001115759100&amp;#127;.&amp;#127;000000000145868575112500
42014081290100&amp;#127;.&amp;#127;00000000015346509325000
48000000048500&amp;#127;.&amp;#127;001241385.50000
48000000048400&amp;#127;.&amp;#127;001241385.150000
;;;;

PROC SQL;
CREATE TABLE JOINED_TABLE AS 
SELECT *
FROM Data201606 T1
LEFT JOIN Data201607 T2 ON ((T1.Var1=T2.Var1 AND T1.Var2=T2.Var2) OR T1.Var1=T2.Var2);
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Jul 2016 11:35:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287742#M59238</guid>
      <dc:creator>sleretrano</dc:creator>
      <dc:date>2016-07-28T11:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way of proc sql joining ON a disjunction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287746#M59241</link>
      <description>&lt;PRE&gt;

Hash Table.
Post your data and the output you want to see .

&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Jul 2016 09:39:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287746#M59241</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-28T09:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way of proc sql joining ON a disjunction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287747#M59242</link>
      <description>Hi, Xia.&lt;BR /&gt;I'm not sure I understand what you mean with the output I want to see.&lt;BR /&gt;The output is huge, the inputs are equally large. I can't possibly do it by hand and SAS takes too long to do it.</description>
      <pubDate>Thu, 28 Jul 2016 09:47:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287747#M59242</guid>
      <dc:creator>sleretrano</dc:creator>
      <dc:date>2016-07-28T09:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way of proc sql joining ON a disjunction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287748#M59243</link>
      <description>&lt;PRE&gt;
I mean make a little example to show what you are looking for . Like :

data a;
input v1 v2 x;
cards;
1 1 1
1 2 2
2 1 2
;
run;
data b;
input v1 v2 x;
cards;
1 1 1
1 2 2
2 1 2
;
run;

output:
........&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Jul 2016 09:52:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287748#M59243</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-28T09:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way of proc sql joining ON a disjunction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287749#M59244</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp﻿&lt;/a&gt;&amp;nbsp;has said, show an example of your data (as a datastep). &amp;nbsp;If the data is the same, why do you have it in two datasets? &amp;nbsp;Identify what needs to be separate, and then put the data into one dataset with a parameter/result setup in a normalised dataset;&lt;BR /&gt;PARAM &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RES&lt;/P&gt;
&lt;P&gt;PERIOD 1 RESULT &amp;nbsp;123&lt;/P&gt;
&lt;P&gt;PERIOD 2 RESULT &amp;nbsp; 345&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can then do many things with that one dataset, by grouping on param for instance, or transposing using param. &amp;nbsp;Its rarely of any benefit to split data up.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2016 10:15:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287749#M59244</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-07-28T10:15:16Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way of proc sql joining ON a disjunction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287750#M59245</link>
      <description>It's not actually the same data set. I thought what I said, even though technically false, would be understandable.&lt;BR /&gt;What I meant is that the data sets have the same variables, but the number of rows and cell values are different.</description>
      <pubDate>Thu, 28 Jul 2016 10:54:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287750#M59245</guid>
      <dc:creator>sleretrano</dc:creator>
      <dc:date>2016-07-28T10:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way of proc sql joining ON a disjunction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287752#M59247</link>
      <description>&lt;P&gt;Yes, but if the datasets are&amp;nbsp;&lt;STRONG&gt;structurally&lt;/STRONG&gt; the same, with the only difference being a value Period, why not put the two datasets together, and have a variable called period. &amp;nbsp;That way you can transpose by period, sort and do datastep processing etc.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2016 11:05:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287752#M59247</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-07-28T11:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way of proc sql joining ON a disjunction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287759#M59250</link>
      <description>&lt;P&gt;I don't think I've made my self clear. The data sets are different on possibly a LOT of values. Furthermore, some variables have the period in their name, which makes them different variables though I was referring to them as being the same variable. Anyway, I posted an example.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2016 11:43:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287759#M59250</guid>
      <dc:creator>sleretrano</dc:creator>
      <dc:date>2016-07-28T11:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way of proc sql joining ON a disjunction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287761#M59251</link>
      <description>&lt;P&gt;Well, I don't know your data so I am only going on what I see posted. &amp;nbsp;It is something that comes up a lot, and it is due to the desire to put "data" in datasetnames (and variables). &amp;nbsp;If you have ever done databasing you will know about normalised fixed data structures which don't change. &amp;nbsp;These are far simpler to work with in SAS also, and SAS is built to do this kind of functioning in built. &amp;nbsp;Lets take your example test data, I create a single table with a fixed structure, putting the "data" from the dataset name into a proper variable in the data so that I can work with it like data. &amp;nbsp;I then present a simple example of transposing the data based on this data using the "data" items created - i.e. no merge, just a transpose with by group.&lt;/P&gt;
&lt;PRE&gt;data data201606;
  length var1 var2 $14 wholebunchofvars_201606 $24;
  format var1 var2 $char14. wholebunchofvars_201606 $char24.;
  informat var1 var2 $char14. wholebunchofvars_201606 $char24.;
  infile datalines4 dlm='7f'x missover dsd;
  input var1 : $char14. var2 : $char14. wholebunchofvars_201606 : $char24.;
datalines4;
42001223829005&amp;#127;42001223821100&amp;#127;1913672811803603960
42001223829005&amp;#127;42001223829100&amp;#127;1913672811803603960
42001223829005&amp;#127;42001223822100&amp;#127;1913672811803603960
42005537849003&amp;#127;42005537841100&amp;#127;1728228741505881940
42000000420200&amp;#127; &amp;#127;149282958163677760150000
42000001251100&amp;#127; &amp;#127;137224761123272858132500
42000002571100&amp;#127; &amp;#127;115006036153103523280000
42000002992100&amp;#127; &amp;#127;176705643184314704200000
42000003721100&amp;#127; &amp;#127;134284160134284151225000
;;;;
run;

data data201607;
  length var1 var2 $14 wholebunchofvars_201607 $24;
  format var1 var2 $char14. wholebunchofvars_201607 $char24.;
  informat var1 var2 $char14. wholebunchofvars_201607 $char24.;
  infile datalines4 dlm='7f'x missover dsd;
  input var1 : $char14. var2 : $char14. wholebunchofvars_201607 : $char24.;
datalines4;
42001223829005&amp;#127;42001223822100&amp;#127;1913672811803603960
42001223829005&amp;#127;42001223821100&amp;#127;1913672811803603960
42001223829005&amp;#127;42001223829100&amp;#127;1913672811803603960
48073274008100&amp;#127;.&amp;#127;..50000
48077274928100&amp;#127;.&amp;#127;..150000
48120011318100&amp;#127;.&amp;#127;..200000
48097297288100&amp;#127;.&amp;#127;..200000
48001314298100&amp;#127;.&amp;#127;..250000
48035295388100&amp;#127;.&amp;#127;..575000
48089429268100&amp;#127;.&amp;#127;..600000
48001012248100&amp;#127;.&amp;#127;..600000
48075642348100&amp;#127;.&amp;#127;..700000
42026909980100&amp;#127;.&amp;#127;000000000.25000
42001115759100&amp;#127;.&amp;#127;000000000145868575112500
42014081290100&amp;#127;.&amp;#127;00000000015346509325000
48000000048500&amp;#127;.&amp;#127;001241385.50000
48000000048400&amp;#127;.&amp;#127;001241385.150000
;;;;
run;

data working_data;
  set data201606 (in=a rename=(wholebunchofvars_201606=wholebunchofvars)) 
      data201607 (in=b rename=(wholebunchofvars_201607=wholebunchofvars));
  period=ifn(a,1,2);
  date=ifn(a,"01JUN2016"d,"01JUL2016"d);
  format date date9.;
run;

proc sort data=working_data;
  by var1 var2 period;
run;
proc transpose data=working_data out=t_work_data;
  by var1 var2;
  var wholebunchofvars;
  id period;
  idlabel period;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2016 12:16:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287761#M59251</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-07-28T12:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way of proc sql joining ON a disjunction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287796#M59256</link>
      <description>&lt;P&gt;For some reason I'm unable to run your code. I&amp;nbsp;attached the error to this message.&amp;nbsp;Do you have any idea what character is causing this?&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12792i68BDC22317B0CE9B/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Prog.jpg" title="Prog.jpg" /&gt;</description>
      <pubDate>Thu, 28 Jul 2016 13:46:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287796#M59256</guid>
      <dc:creator>sleretrano</dc:creator>
      <dc:date>2016-07-28T13:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way of proc sql joining ON a disjunction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287797#M59257</link>
      <description>&lt;P&gt;I posted an example. Thank you for your time.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2016 13:49:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287797#M59257</guid>
      <dc:creator>sleretrano</dc:creator>
      <dc:date>2016-07-28T13:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way of proc sql joining ON a disjunction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287829#M59260</link>
      <description>&lt;P&gt;Yes, there was something odd when I copied out from the test data you gave to my environment, it shows a square between some of the data. &amp;nbsp;Must be the different system encodings. &amp;nbsp;Anyways, if you take your original test data, and copy from below the datalines to the ;;;; and replace that in the code you run, it should be fine. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could be something wierd with the website too. &amp;nbsp;This is what I see when I copy your test data to my system:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/4306iDE4653E3B9CB0F62/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2016 14:53:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287829#M59260</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-07-28T14:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way of proc sql joining ON a disjunction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287850#M59266</link>
      <description>No luck. The problem is when it rans the working_data data step.</description>
      <pubDate>Thu, 28 Jul 2016 15:41:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287850#M59266</guid>
      <dc:creator>sleretrano</dc:creator>
      <dc:date>2016-07-28T15:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way of proc sql joining ON a disjunction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287852#M59267</link>
      <description>&lt;P&gt;Not sure what to suggest, I just copied it out of the website and ran it, worked fine. &amp;nbsp;Have you tried a new session? &amp;nbsp;Does the code look the same as on here, it just looks like some special character is messing it up.&lt;/P&gt;
&lt;P&gt;Try copying and pasting the whole text into Notepad first.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2016 15:51:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287852#M59267</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-07-28T15:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way of proc sql joining ON a disjunction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287858#M59269</link>
      <description>I did try a new session and also tried to copy to Notepad first, still didn't work. I too am at a loss.&lt;BR /&gt;&lt;BR /&gt;Thanks for the tips.</description>
      <pubDate>Thu, 28 Jul 2016 16:03:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/287858#M59269</guid>
      <dc:creator>sleretrano</dc:creator>
      <dc:date>2016-07-28T16:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way of proc sql joining ON a disjunction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/288039#M59349</link>
      <description>&lt;PRE&gt;
You didn't post the output when T1.Var1=T2.Var2  yet ?




DATA Data201606;
    LENGTH
        Var1             $ 14
        Var2             $ 14
        WholeBunchOfVars_201606 $ 24 ;
    FORMAT
        Var1             $CHAR14.
        Var2             $CHAR14.
        WholeBunchOfVars_201606 $CHAR24. ;
    INFORMAT
        Var1             $CHAR14.
        Var2             $CHAR14.
        WholeBunchOfVars_201606 $CHAR24. ;
    INFILE DATALINES4
        DLM='7F'x
        MISSOVER
        DSD ;
    INPUT
        Var1             : $CHAR14.
        Var2             : $CHAR14.
        WholeBunchOfVars_201606 : $CHAR24. ;
DATALINES4;
42001223829005&amp;#127;42001223821100&amp;#127;1913672811803603960
42001223829005&amp;#127;42001223829100&amp;#127;1913672811803603960
42001223829005&amp;#127;42001223822100&amp;#127;1913672811803603960
42005537849003&amp;#127;42005537841100&amp;#127;1728228741505881940
42000000420200&amp;#127; &amp;#127;149282958163677760150000
42000001251100&amp;#127; &amp;#127;137224761123272858132500
42000002571100&amp;#127; &amp;#127;115006036153103523280000
42000002992100&amp;#127; &amp;#127;176705643184314704200000
42000003721100&amp;#127; &amp;#127;134284160134284151225000
;;;;

DATA Data201607;
    LENGTH
        Var1             $ 14
        Var2             $ 14
        WholeBunchOfVars_201607 $ 24 ;
    FORMAT
        Var1             $CHAR14.
        Var2             $CHAR14.
        WholeBunchOfVars_201607 $CHAR24. ;
    INFORMAT
        Var1             $CHAR14.
        Var2             $CHAR14.
        WholeBunchOfVars_201607 $CHAR24. ;
    INFILE DATALINES4
        DLM='7F'x
        MISSOVER
        DSD ;
    INPUT
        Var1             : $CHAR14.
        Var2             : $CHAR14.
        WholeBunchOfVars_201607 : $CHAR24. ;
DATALINES4;
42001223829005&amp;#127;42001223822100&amp;#127;1913672811803603960
42001223829005&amp;#127;42001223821100&amp;#127;1913672811803603960
42001223829005&amp;#127;42001223829100&amp;#127;1913672811803603960
48073274008100&amp;#127;.&amp;#127;..50000
48077274928100&amp;#127;.&amp;#127;..150000
48120011318100&amp;#127;.&amp;#127;..200000
48097297288100&amp;#127;.&amp;#127;..200000
48001314298100&amp;#127;.&amp;#127;..250000
48035295388100&amp;#127;.&amp;#127;..575000
48089429268100&amp;#127;.&amp;#127;..600000
48001012248100&amp;#127;.&amp;#127;..600000
48075642348100&amp;#127;.&amp;#127;..700000
42026909980100&amp;#127;.&amp;#127;000000000.25000
42001115759100&amp;#127;.&amp;#127;000000000145868575112500
42014081290100&amp;#127;.&amp;#127;00000000015346509325000
48000000048500&amp;#127;.&amp;#127;001241385.50000
48000000048400&amp;#127;.&amp;#127;001241385.150000
;;;;


data want;
 if _n_=1 then do;
  if 0 then set Data201607;
  declare hash h1(dataset:'Data201607',multidata:'y');
  h1.definekey('Var1','Var2');
  h1.definedata('WholeBunchOfVars_201607 ');
  h1.definedone();
  
  declare hash h2(dataset:'Data201607',multidata:'y');
  h2.definekey('Var2');
  h2.definedata('WholeBunchOfVars_201607 ');
  h2.definedone();
 end;
call missing(of _all_);
set Data201606;
 rc=h1.find();
 if rc=0 then do;
  do while(rc=0);
   output;
   rc=h1.find_next();
  end;
 end;
  else do;
         rx=h2.find(key:var1);
         if rx=0 then do;
           do while(rx=0);
            output;
            rx=h1.find_next();
           end;
         end;
         else output;
        end;
drop rc rx;
run;



&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Jul 2016 05:39:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/288039#M59349</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-29T05:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way of proc sql joining ON a disjunction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/288072#M59358</link>
      <description>I didn't post the output because I don't really care what the output looks like. What matters to me is the join condition.&lt;BR /&gt;This seems to do what I want.&lt;BR /&gt;Thank you very much.</description>
      <pubDate>Fri, 29 Jul 2016 09:05:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-of-proc-sql-joining-ON-a-disjunction/m-p/288072#M59358</guid>
      <dc:creator>sleretrano</dc:creator>
      <dc:date>2016-07-29T09:05:22Z</dc:date>
    </item>
  </channel>
</rss>

