<?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: Matching all records in data1 to one row dataset data2 on variable list x1-x&amp;amp;k in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Matching-all-records-in-data1-to-one-row-dataset-data2-on/m-p/787994#M40062</link>
    <description>&lt;P&gt;Looks to me like you just want to do a simple MERGE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data join1;
  merge d1 d2;
  by x1-x4 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 01 Jan 2022 18:32:21 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-01-01T18:32:21Z</dc:date>
    <item>
      <title>Matching all records in data1 to one row dataset data2 on variable list x1-x&amp;k</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Matching-all-records-in-data1-to-one-row-dataset-data2-on/m-p/787990#M40059</link>
      <description>&lt;P&gt;Say I have simulated data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data d1;
do i=1 to 1000;
  x1=rand('binomial',.1,1);
  x2=rand('binomial',.3,1);
  x3=rand('binomial',.6,1);&lt;BR /&gt;  x4=rand('binomial',.8,1);
  y=x1+x2+x3+x4;
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and a second one row dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data d2;
input x1 x2 x3 x4;
cards;
0 0 0 0
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and I want join on the list of all x variables x1-x4 in d2 without typing a long ON statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let k=4;
proc sql;
create table join1 as
select a.*, b.*
from d1 a, d1 b
on x1:x&amp;amp;k;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is there a quick way to do this or do I need to perhaps use a macro to construct a string "on a.x1=b.x1, a.x2=b.x2, . . ."?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jan 2022 17:20:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Matching-all-records-in-data1-to-one-row-dataset-data2-on/m-p/787990#M40059</guid>
      <dc:creator>RobertWF1</dc:creator>
      <dc:date>2022-01-01T17:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: Matching all records in data1 to one row dataset data2 on variable list x1-x&amp;k</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Matching-all-records-in-data1-to-one-row-dataset-data2-on/m-p/787991#M40060</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this what you want? :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data d1;
do i=1 to 1000;
  x1=rand('binomial',.1,1);
  x2=rand('binomial',.3,1);
  x3=rand('binomial',.6,1);  
  x4=rand('binomial',.8,1);
  y=x1+x2+x3+x4;
output;
end;
run;

data d2;
input x1 x2 x3 x4;
cards;
0 0 0 0
;
run;

PROC SQL noprint;
 select 'a.' || strip(name) || '=b.' || strip(name) into :mymv separated by ' AND '
 from dictionary.columns
 where libname='WORK' and memname='D2';
QUIT;
%PUT &amp;amp;=mymv;

*%let k=4;
proc sql;
create table join1 as
select a.* /* , b.* */
from d1 as a, d2 as b
where &amp;amp;mymv.;
quit;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jan 2022 17:44:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Matching-all-records-in-data1-to-one-row-dataset-data2-on/m-p/787991#M40060</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-01-01T17:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: Matching all records in data1 to one row dataset data2 on variable list x1-x&amp;k</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Matching-all-records-in-data1-to-one-row-dataset-data2-on/m-p/787993#M40061</link>
      <description>Perfect! &lt;BR /&gt;&lt;BR /&gt;But how exactly does the following code work?&lt;BR /&gt;&lt;BR /&gt;PROC SQL noprint;&lt;BR /&gt; select 'a.' || strip(name) || '=b.' || strip(name) into :mymv separated by ' AND '&lt;BR /&gt; from dictionary.columns&lt;BR /&gt; where libname='WORK' and memname='D2';&lt;BR /&gt;QUIT;&lt;BR /&gt;&lt;BR /&gt;I'm not familiar with "dictionary.columns", "names", and "memnames" - are they new features in SAS that let you work with metadata?</description>
      <pubDate>Sat, 01 Jan 2022 18:25:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Matching-all-records-in-data1-to-one-row-dataset-data2-on/m-p/787993#M40061</guid>
      <dc:creator>RobertWF1</dc:creator>
      <dc:date>2022-01-01T18:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: Matching all records in data1 to one row dataset data2 on variable list x1-x&amp;k</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Matching-all-records-in-data1-to-one-row-dataset-data2-on/m-p/787994#M40062</link>
      <description>&lt;P&gt;Looks to me like you just want to do a simple MERGE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data join1;
  merge d1 d2;
  by x1-x4 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Jan 2022 18:32:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Matching-all-records-in-data1-to-one-row-dataset-data2-on/m-p/787994#M40062</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-01T18:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: Matching all records in data1 to one row dataset data2 on variable list x1-x&amp;k</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Matching-all-records-in-data1-to-one-row-dataset-data2-on/m-p/787995#M40063</link>
      <description>&lt;P&gt;If you do not need to use SQL :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data d1;
do i=1 to 1000;
  x1=rand('binomial',.1,1);
  x2=rand('binomial',.3,1);
  x3=rand('binomial',.6,1);  x4=rand('binomial',.8,1);
  y=x1+x2+x3+x4;
output;
end;
run;

data d2;
input x1 x2 x3 x4;
cards;
0 0 0 0
;
run;

data want;

   if _N_ = 1 then do;
      dcl hash h(dataset : "d2(keep = x:)");
	  h.definekey(all : "Y");
	  h.definedone();
   end;

   set d1;

   if h.check() = 0;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Jan 2022 18:38:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Matching-all-records-in-data1-to-one-row-dataset-data2-on/m-p/787995#M40063</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-01-01T18:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: Matching all records in data1 to one row dataset data2 on variable list x1-x&amp;k</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Matching-all-records-in-data1-to-one-row-dataset-data2-on/m-p/787997#M40064</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/408179"&gt;@RobertWF1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The dictionary tables have always been part of SAS (afaik).&lt;/P&gt;
&lt;P&gt;The SASHELP library has views on these dictionary tables.&lt;/P&gt;
&lt;P&gt;Look for example at SASHELP.VCOLUMN (dictionary.columns), SASHELP.VTABLE (dictionary.tables), SASHELP.VLIBNAM etc ...&lt;BR /&gt;See here :&lt;BR /&gt;SAS® 9.4 and SAS® Viya® 3.5 Programming Documentation&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/p06tcw6zjh3vm6n19vpkj0mxs5gi.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/p06tcw6zjh3vm6n19vpkj0mxs5gi.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jan 2022 20:14:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Matching-all-records-in-data1-to-one-row-dataset-data2-on/m-p/787997#M40064</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-01-01T20:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: Matching all records in data1 to one row dataset data2 on variable list x1-x&amp;k</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Matching-all-records-in-data1-to-one-row-dataset-data2-on/m-p/788025#M40065</link>
      <description>&lt;P&gt;NATRUAL JOIN could save your time .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
create table join1 as
select a.*, b.*
from d1 a natural inner join  d1 b
;
quit;&lt;/PRE&gt;</description>
      <pubDate>Sun, 02 Jan 2022 10:27:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Matching-all-records-in-data1-to-one-row-dataset-data2-on/m-p/788025#M40065</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-01-02T10:27:44Z</dc:date>
    </item>
  </channel>
</rss>

