<?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 How to get Cartesian product in Datastep in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120507#M259666</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;EM&gt;Hello All.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Is there any way to get&lt;/EM&gt; &lt;STRONG&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;Cartesian product &lt;/EM&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;between two datasets in Datasetp???&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;I was doing some learning process on difference between Merge and Joins.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;I can able to get left join and right joins in the datastep by using IN options.but i am not sure how to get &lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN class="st"&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;Cartesian product &lt;/EM&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;in the datastep.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;It it not my requirement but i just want know how to achieve this.&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;Could any one help me on this to get clarify..&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;Thanks&amp;amp; Regards.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;Sanjeev.K&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 25 Apr 2013 12:11:53 GMT</pubDate>
    <dc:creator>kuridisanjeev</dc:creator>
    <dc:date>2013-04-25T12:11:53Z</dc:date>
    <item>
      <title>How to get Cartesian product in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120507#M259666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;EM&gt;Hello All.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Is there any way to get&lt;/EM&gt; &lt;STRONG&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;Cartesian product &lt;/EM&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;between two datasets in Datasetp???&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;I was doing some learning process on difference between Merge and Joins.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;I can able to get left join and right joins in the datastep by using IN options.but i am not sure how to get &lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN class="st"&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;Cartesian product &lt;/EM&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;in the datastep.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;It it not my requirement but i just want know how to achieve this.&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;Could any one help me on this to get clarify..&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;Thanks&amp;amp; Regards.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;Sanjeev.K&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Apr 2013 12:11:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120507#M259666</guid>
      <dc:creator>kuridisanjeev</dc:creator>
      <dc:date>2013-04-25T12:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Cartesian product in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120508#M259667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sanjeev&lt;/P&gt;&lt;P&gt;You may get someone providing you with a working solution to obtaining a Cartesian product using a data step but why would you bother?&amp;nbsp; Proc SQL does this without any fuss.&amp;nbsp; Anything else is just creating a roundabout way to solve a simple problem.&amp;nbsp; Do you have a business case for what you are asking?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Apr 2013 12:23:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120508#M259667</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2013-04-25T12:23:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Cartesian product in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120509#M259668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It isnt part of the merge on a data step but here is a reference and code for catresian in a datastep&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/kb/24/652.html" title="http://support.sas.com/kb/24/652.html"&gt;24652 - Generate every combination of observations between data sets&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data every_combination;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* Set one of your data sets, usually the larger data set */&lt;/P&gt;&lt;P&gt;&amp;nbsp; set one;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 to n;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* For every observation in the first data set,&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* read in each observation in the second data set */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set two point=i nobs=n;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EJ&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UPDATE -- Richard is right -- learning aside -- I did cartesians in SQL only &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Apr 2013 12:26:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120509#M259668</guid>
      <dc:creator>esjackso</dc:creator>
      <dc:date>2013-04-25T12:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Cartesian product in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120510#M259669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And of course .don't forget Hash Table could also get it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Apr 2013 12:39:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120510#M259669</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2013-04-25T12:39:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Cartesian product in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120511#M259670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;Hi&lt;/STRONG&gt; &lt;STRONG class="font-color-meta"&gt;&lt;SPAN class="replyToName"&gt;Richardi.&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG class="font-color-meta"&gt;&lt;SPAN class="replyToName"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class="replyToName"&gt;As i already mentioned in my post,"&lt;STRONG&gt;it is not my Actual requirement"&lt;/STRONG&gt;,but i just want to know. how can we approach the datastep to do this.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class="replyToName"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class="replyToName"&gt;In a learning process,i tried all the SQL joins in datastep like &lt;STRONG&gt;Left,Right,Inner,Outer&lt;/STRONG&gt; Etc.But i was &lt;/SPAN&gt;&lt;/EM&gt;&lt;EM&gt;&lt;SPAN class="vk_ans vk_bk"&gt;struck with&amp;nbsp; &lt;/SPAN&gt;&lt;/EM&gt;&lt;STRONG&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;Cartesian product.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;I too always prefer SQL join to get &lt;/EM&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;Cartesian product &lt;/EM&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;because its straight forward and simple and it wont required much coding as well.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;I am using This Communities forum&amp;nbsp;&amp;nbsp; &lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;as a learning opportunity to get clarify many Hidden this in SAS ,even Those requirements not comes into the picture of real time.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;&amp;nbsp; &lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN class="st"&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN class="st"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;EM&gt;Don't mind if i&amp;nbsp; am posting few&amp;nbsp; silly requirements.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Regards.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Sanjeev.K&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Apr 2013 13:04:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120511#M259670</guid>
      <dc:creator>kuridisanjeev</dc:creator>
      <dc:date>2013-04-25T13:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Cartesian product in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120512#M259671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;FWIW, Eric's code is good when you do Cartesian Product over two tables from top to toe. However, if doing it using BY variables (Doing Cartesian Products within groups, such as many to many join), then Hash() seems to be the only data-step way to go.&lt;/P&gt;&lt;P&gt;On another note, I would generally agree with Richard's comments regarding SQL, which is built natively to do Cartesian product. But from some of my own experiences, sometimes Hash() does hold a performance edge over Proc SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just my 2 cents,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Apr 2013 13:16:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120512#M259671</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-04-25T13:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Cartesian product in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120513#M259672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want all the observations from A and all the observations from B, just "stack the datasets".&lt;/P&gt;&lt;P&gt;data fileAB;&lt;/P&gt;&lt;P&gt;set fileA fileB;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;***********************&lt;/P&gt;&lt;P&gt;If you want all the data from A and B with a common identifier (ID).&lt;/P&gt;&lt;P&gt;data fileAB;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; merge fileA(in=a) fileB(in=b);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by ID;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if a and b;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Apr 2013 14:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120513#M259672</guid>
      <dc:creator>donevans</dc:creator>
      <dc:date>2013-04-25T14:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Cartesian product in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120514#M259673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you need the Cartesian product within BY variables, there is another way that a DATA step can accomplish this.&amp;nbsp; It's not necessarily the best way, but here's the approach FWIW.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the smaller data set, sort it.&amp;nbsp; Then construct a format that translates the BY variable's value into two pieces of information:&amp;nbsp; the first and last observation number in the sorted data that matches that BY value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then perform the "join".&amp;nbsp; Read in an observation from the larger data set, use the format to retrieve which observation numbers match the value of the "BY" variable, and retrieve them using point=.&amp;nbsp; Altogether, it's probably 20 lines of code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Apr 2013 15:18:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120514#M259673</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-04-25T15:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Cartesian product in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120515#M259674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow, Astounding! You are squeezing the last drop of juice from conventional data step, very impressed!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Apr 2013 02:46:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120515#M259674</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-04-26T02:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Cartesian product in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120516#M259675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, as I predicted a number of people responded to your challenge, proving&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Some people will enjoy devising ingenious solutions to problems even if they have no practical implementation.&amp;nbsp; "Art for Art's sake."&amp;nbsp; Well enough.&lt;/LI&gt;&lt;LI&gt;The SAS data step is a very powerful beast in the right hands.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would not regard this exercise as a "learning opportunity to get clarity".&amp;nbsp; Your best learning opportunities are taking the SAS training; reading the SAS documentation (I would recommend bookmarking functions, formats, and commonly used procs like SQL, MEANS, FREQ), and asking your more experienced colleagues to explain something you do not understand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Apr 2013 02:01:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120516#M259675</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2013-04-27T02:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Cartesian product in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120517#M259676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Need to understand why SAS system generate merging in data step as SQL&amp;nbsp; is already done all those work .. its all about the way we think ...I think we need more enhance processing&amp;nbsp; we need to do new function and then they created this algorithms .. because any other system can't do what merge is doing here in terms of technical processing&amp;nbsp; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if they only need to build a &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Cartesian product&lt;/SPAN&gt; they never find the this merge process ..&lt;/P&gt;&lt;P&gt;and if there is possible to generate the Cartesian product .. i am also interested to know .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But my think is always towards find the efficient and more simple function of processing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jan 2014 15:35:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120517#M259676</guid>
      <dc:creator>AjayKant</dc:creator>
      <dc:date>2014-01-17T15:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Cartesian product in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120518#M259677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As you are in learning approach.&lt;/P&gt;&lt;P&gt;The cartesian product is mathematical simple but can be for real execution a no go having bigger datasets.&lt;/P&gt;&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/magazine/cc301622.aspx" title="http://msdn.microsoft.com/en-us/magazine/cc301622.aspx"&gt;Data Points: Five Ways to Rev up Your SQL Performance&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For real big data problems there is move to NOSQL &lt;A href="http://en.wikipedia.org/wiki/NoSQL" title="http://en.wikipedia.org/wiki/NoSQL"&gt;NoSQL - Wikipedia, the free encyclopedia&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Do we not have something there that is nosql?.... SAS datastep&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 19 Jan 2014 08:18:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120518#M259677</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-01-19T08:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Cartesian product in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120519#M259678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The SAS data step pre-dates the commercial implementation of SQL.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 19 Jan 2014 15:18:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120519#M259678</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-01-19T15:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Cartesian product in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120520#M259679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hashing in SAS was added with SAS V9. SQL was already present in SAS V6.&lt;/P&gt;&lt;P&gt;NoSql is hyping today but with a closer look at that the same kind of technical approaches as in the time of the PC-XT.&lt;/P&gt;&lt;P&gt;The basic question is also the same:&lt;/P&gt;&lt;P&gt;"what to do when a simple logical approach is going beyond comfort-zone when trying to implement it".&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 19 Jan 2014 15:28:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/120520#M259679</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-01-19T15:28:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Cartesian product in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/238967#M259680</link>
      <description>&lt;P&gt;I think a hash table would&amp;nbsp;look up at most one row. &amp;nbsp;So the resulting dataset would not be a Cartesian product.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2015 19:20:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/238967#M259680</guid>
      <dc:creator>Brian_C_Brown</dc:creator>
      <dc:date>2015-12-11T19:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Cartesian product in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/238969#M259681</link>
      <description>&lt;P&gt;I think you could get a Cartesian product if you perform a MERGE using variables with one single common value for all rows in both datasets.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2015 19:23:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/238969#M259681</guid>
      <dc:creator>Brian_C_Brown</dc:creator>
      <dc:date>2015-12-11T19:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Cartesian product in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/403478#M259682</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I have a process where I do a Cartesian product of 2 tables&amp;nbsp; (one with data and one with parameters) using proc sql and then I use data step to apply the needed filters so that at the end only the lines where the data matches the parameter remain.&lt;BR /&gt;&lt;BR /&gt;As you can imagine this is a very inefficient process and so I'm trying to use this approach to and/or merge to apply the filters during the cross join so that the process becomes more effecient. But unfortunately it doesn't seem to be working since and don't get the same results in both cases.&lt;BR /&gt;&lt;BR /&gt;Here is a sample of what I'm doing:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    data campanha_000_testes;
    set base
      do i=1 to n;

        set parameter point=i nobs=n;


    if id = 000 and SYSTEM NE 'BBBB' then delete;

        
            if not missing('oferta Origem'n) then
                do;
                    if compress('oferta Origem'n) = compress(pack_dsc);
                end;

                    if find(RP_ID_EXCLUDE,compress(put(pack_cod,10.))) then delete;
                end;

            if not missing(Desconto_mens_max) then
                do;
                    if Desconto_mens_min &amp;lt;= Beneficio &amp;lt;=Desconto_mens_max;
                end;

            if not missing(mensalidade_maxima) then
                do;
                    *distinguir a abordagem;
                    if abordagem in ('Client','Conta') and id ne 303 then
                        do;
                            if mensalidade_minima &amp;lt; mens_liq_conta &amp;lt;= mensalidade_maxima;
                        end;
                    else if compress(abordagem) in ('Client','Conta') and id = 303 then
                        do;
                            if mensalidade_minima &amp;lt; mens_liq_im_conta &amp;lt;= mensalidade_maxima;
                        end;
                    else if abordagem = 'NIF' then
                        do;
                            if mensalidade_minima &amp;lt; mens_liq_NIF &amp;lt;= mensalidade_maxima;
                        end;
                    else
                        do;
                            if Mensalidade_Minima &amp;lt; Mensalidade_Liq_Siva &amp;lt;= Mensalidade_maxima;
                        end;
                end;

            output;

      end;

        run;


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any ideas on how to perform this?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 09:37:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/403478#M259682</guid>
      <dc:creator>Ricardo_Neves</dc:creator>
      <dc:date>2017-10-12T09:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Cartesian product in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/403497#M259683</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/65256"&gt;@Brian_C_Brown&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;You can iterate over&amp;nbsp;the full&amp;nbsp;hash table either by using an ITER object or by loading the hash with a single value key for all rows and then use the do_over() method.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 11:32:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/403497#M259683</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-10-12T11:32:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Cartesian product in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/403498#M259684</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/65256"&gt;@Brian_C_Brown&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I think you could get a Cartesian product if you perform a MERGE using variables with one single common value for all rows in both datasets.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/65256"&gt;@Brian_C_Brown&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;That won't work! And the reason why it won't work will explain the main difference between the outcome of a SQL join and a SAS data step merge. I suggest you give it a go with some sample data and code and then try to understand what happened - or come back here and ask the question.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 11:35:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/403498#M259684</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-10-12T11:35:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Cartesian product in Datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/858198#M339080</link>
      <description>&lt;P&gt;THanks. The code really helped me to get cartesian type prod&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 05:46:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-Cartesian-product-in-Datastep/m-p/858198#M339080</guid>
      <dc:creator>UmaSingh</dc:creator>
      <dc:date>2023-02-10T05:46:27Z</dc:date>
    </item>
  </channel>
</rss>

