<?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: cartesian product with 3 tables through datastep in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/cartesian-product-with-3-tables-through-datastep/m-p/716994#M221688</link>
    <description>&lt;P&gt;Maxim 14: Use the Right Tool.&lt;/P&gt;
&lt;P&gt;Which means that &lt;U&gt;this&lt;/U&gt; is the right SAS code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select *
  from min_scoperto_1, scoperto_1, limite_1
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But you already have the data step method for 2 datasets; just nest a second DO loop for the third dataset inside the DO loop you already have for the second dataset.&lt;/P&gt;</description>
    <pubDate>Fri, 05 Feb 2021 08:33:53 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-02-05T08:33:53Z</dc:date>
    <item>
      <title>cartesian product with 3 tables through datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cartesian-product-with-3-tables-through-datastep/m-p/716991#M221686</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I'm looking to create a cartesian product with 3 tables through datastep where 3 tables are following:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; min_scoperto_1;&lt;/P&gt;
&lt;P&gt;input min_Scoperto $;&lt;/P&gt;
&lt;P&gt;datalines;&lt;/P&gt;
&lt;P&gt;0.01&lt;/P&gt;
&lt;P&gt;0.02&lt;/P&gt;
&lt;P&gt;0.03&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; scoperto_1;&lt;/P&gt;
&lt;P&gt;input Scoperto $;&lt;/P&gt;
&lt;P&gt;datalines;&lt;/P&gt;
&lt;P&gt;0.1&lt;/P&gt;
&lt;P&gt;0.2&lt;/P&gt;
&lt;P&gt;0.3&lt;/P&gt;
&lt;P&gt;0.5&lt;/P&gt;
&lt;P&gt;1.0&lt;/P&gt;
&lt;P&gt;2.0&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; limite_1;&lt;/P&gt;
&lt;P&gt;input limite $;&lt;/P&gt;
&lt;P&gt;datalines;&lt;/P&gt;
&lt;P&gt;40&lt;/P&gt;
&lt;P&gt;50&lt;/P&gt;
&lt;P&gt;60&lt;/P&gt;
&lt;P&gt;70&lt;/P&gt;
&lt;P&gt;80&lt;/P&gt;
&lt;P&gt;90&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;For two tables - through datastep - the right code is the following&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; c;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set LIMITE_1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; do i=&lt;STRONG&gt;1&lt;/STRONG&gt; to n;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set SCOPERTO_1 point=i nobs=n;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which is the right sas code through datastep for the 3 tables?&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;P&gt;max&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 08:22:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cartesian-product-with-3-tables-through-datastep/m-p/716991#M221686</guid>
      <dc:creator>max_ros</dc:creator>
      <dc:date>2021-02-05T08:22:05Z</dc:date>
    </item>
    <item>
      <title>Re: cartesian product with 3 tables through datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cartesian-product-with-3-tables-through-datastep/m-p/716994#M221688</link>
      <description>&lt;P&gt;Maxim 14: Use the Right Tool.&lt;/P&gt;
&lt;P&gt;Which means that &lt;U&gt;this&lt;/U&gt; is the right SAS code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select *
  from min_scoperto_1, scoperto_1, limite_1
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But you already have the data step method for 2 datasets; just nest a second DO loop for the third dataset inside the DO loop you already have for the second dataset.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 08:33:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cartesian-product-with-3-tables-through-datastep/m-p/716994#M221688</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-05T08:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: cartesian product with 3 tables through datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cartesian-product-with-3-tables-through-datastep/m-p/716996#M221690</link>
      <description>&lt;P&gt;SQL will even outperform the data step loops once the datasets grow:&lt;/P&gt;
&lt;PRE&gt; 72         
 73         data t1;
 74         do var1 = 1 to 300;
 75           output;
 76         end;
 77         run;
 
 NOTE: The data set WORK.T1 has 300 observations and 1 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 78         
 79         data t2;
 80         do var2 = 1 to 300;
 81           output;
 82         end;
 83         run;
 
 NOTE: The data set WORK.T2 has 300 observations and 1 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 84         
 85         data t3;
 86         do var3 = 1 to 300;
 87           output;
 88         end;
 89         run;
 
 NOTE: The data set WORK.T3 has 300 observations and 1 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 90         
 91         proc sql;
 92         create table t4_1 as
 93           select *
 94           from t1, t2, t3
 95         ;
 NOTE: The execution of this query involves performing one or more Cartesian product joins that can not be optimized.
 NOTE: Table WORK.T4_1 created, with 27000000 rows and 3 columns.
 
 96         quit;
 NOTE:  Verwendet wurde: PROZEDUR SQL - (Gesamtverarbeitungszeit):
       real time           5.47 seconds
       cpu time            2.45 seconds
       
 
 97         
 98         data t4_2;
 99         set t1;
 100        do i = 1 to n1;
 101          set t2 point=i nobs=n1;
 102          do j = 1 to n2;
 103            set t3 point=j nobs=n2;
 104            output;
 105          end;
 106        end;
 107        run;
 
 NOTE: There were 300 observations read from the data set WORK.T1.
 NOTE: The data set WORK.T4_2 has 27000000 observations and 3 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           7.87 seconds
       cpu time            4.71 seconds
&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Feb 2021 08:47:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cartesian-product-with-3-tables-through-datastep/m-p/716996#M221690</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-05T08:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: cartesian product with 3 tables through datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cartesian-product-with-3-tables-through-datastep/m-p/717000#M221693</link>
      <description>thankyou so much!</description>
      <pubDate>Fri, 05 Feb 2021 08:54:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cartesian-product-with-3-tables-through-datastep/m-p/717000#M221693</guid>
      <dc:creator>max_ros</dc:creator>
      <dc:date>2021-02-05T08:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: cartesian product with 3 tables through datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cartesian-product-with-3-tables-through-datastep/m-p/717001#M221694</link>
      <description>&lt;P&gt;tks a lot!&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 08:55:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cartesian-product-with-3-tables-through-datastep/m-p/717001#M221694</guid>
      <dc:creator>max_ros</dc:creator>
      <dc:date>2021-02-05T08:55:38Z</dc:date>
    </item>
  </channel>
</rss>

