<?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: creating pairs of observations that has common values in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/creating-pairs-of-observations-that-has-common-values/m-p/418655#M12802</link>
    <description>&lt;P&gt;A simple SQL join will do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input class	student $ var1;
datalines;
1	A	11
1	B	12
1	C	13
1	D	14
2	A	11
2	B	12
2	E	1
;

proc sql;
create table want as
select 
    a.class,
    a.student as student1,
    b.student as student2,
    a.var1,
    b.var1 as var2
from 
    have as a inner join 
    have as b on a.class=b.class;
select * from want;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 06 Dec 2017 01:21:16 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2017-12-06T01:21:16Z</dc:date>
    <item>
      <title>creating pairs of observations that has common values</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/creating-pairs-of-observations-that-has-common-values/m-p/418645#M12799</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;I would like to create pairs of observation that have the same value in a variable. Say if students A,&amp;nbsp;B,&amp;nbsp;C, D are in the same class then I would create some pairs AB,AC, AD, BC,BD, CD. pair with itself (AA, BB, CC) is ok.&lt;BR /&gt;My input dataset is:
class	student	var1
1	A	11
1	B	12
1	C	13
1	D	14
2	A	11
2	B	12
2	E	1
 	 	 
Wanted Output is:
class	student1	student2	var1	var2
1	A	A	11	11
1	A	B	11	12
1	A	C	11	13
1	A	D	11	14
1	B	A	12	11
1	B	B	12	12
1	B	C	12	13
1	B	D	12	14
1	C	A	13	11
1	C	B	13	12
1	C	C	13	13
1	C	D	13	14
1	D	A	14	11
1	D	B	14	12
1	D	C	14	13
1	D	D	14	14
2	A	A	11	11
2	A	B	11	12
2	A	E	11	1
2	B	A	12	11
2	B	B	12	12
2	B	E	12	1
2	E	A	1	11
2	E	B	1	12
2	E	E	1	1&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Dec 2017 00:40:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/creating-pairs-of-observations-that-has-common-values/m-p/418645#M12799</guid>
      <dc:creator>somebody</dc:creator>
      <dc:date>2017-12-06T00:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: creating pairs of observations that has common values</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/creating-pairs-of-observations-that-has-common-values/m-p/418647#M12800</link>
      <description>&lt;P&gt;Try a SQL Cross Join&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/98381"&gt;@somebody&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;My input dataset is:
class	student	var1
1	A	11
1	B	12
1	C	13
1	D	14
2	A	11
2	B	12
2	E	1
 	 	 
Wanted Output is:
class	student1	student2	var1	var2
1	A	A	11	11
1	A	B	11	12
1	A	C	11	13
1	A	D	11	14
1	B	A	12	11
1	B	B	12	12
1	B	C	12	13
1	B	D	12	14
1	C	A	13	11
1	C	B	13	12
1	C	C	13	13
1	C	D	13	14
1	D	A	14	11
1	D	B	14	12
1	D	C	14	13
1	D	D	14	14
2	A	A	11	11
2	A	B	11	12
2	A	E	11	1
2	B	A	12	11
2	B	B	12	12
2	B	E	12	1
2	E	A	1	11
2	E	B	1	12
2	E	E	1	1&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 00:52:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/creating-pairs-of-observations-that-has-common-values/m-p/418647#M12800</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-06T00:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: creating pairs of observations that has common values</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/creating-pairs-of-observations-that-has-common-values/m-p/418655#M12802</link>
      <description>&lt;P&gt;A simple SQL join will do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input class	student $ var1;
datalines;
1	A	11
1	B	12
1	C	13
1	D	14
2	A	11
2	B	12
2	E	1
;

proc sql;
create table want as
select 
    a.class,
    a.student as student1,
    b.student as student2,
    a.var1,
    b.var1 as var2
from 
    have as a inner join 
    have as b on a.class=b.class;
select * from want;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Dec 2017 01:21:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/creating-pairs-of-observations-that-has-common-values/m-p/418655#M12802</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-12-06T01:21:16Z</dc:date>
    </item>
  </channel>
</rss>

