<?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: Join 4 tables using proc sql to check consistency across multiple datasets? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Join-4-tables-using-proc-sql-to-check-consistency-across/m-p/372464#M65171</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Thanks Kurt, i just corrected typo and misplaced variables. Now I get new error. Any suggestions as to what am I missing? Thanks again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; 
create table outer as 
	select 	a.groupc,  a.subjc, 
		b.groupd,  b.subjd, 
		c.group7d, c.subj7d,
		d.group3m, d.subj3m
	from 	groupc  as a, 
		groupd  as b, 
		group7d as c, 
		group3m as d 
	full join groupc  on a.groupc =  b.groupd  and a.subjc  = b.subjd 
	full join groupc  on a.groupc =  c.group7d and a.subjc  = c.subj7d
	full join groupd  on b.groupd =  c.group7d and b.subjd  = c.subj7d
	full join group7d on c.group7d = d.group3m and c.subj7d = d.subj3m&lt;BR /&gt;        where d.subj3m is null;
quit; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;New error in the log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: Correlated reference to column groupc is not contained within a subquery.
ERROR: Correlated reference to column groupd is not contained within a subquery.
ERROR: Correlated reference to column subjc is not contained within a subquery.
ERROR: Correlated reference to column subjd is not contained within a subquery.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 01 Jul 2017 23:21:40 GMT</pubDate>
    <dc:creator>Cruise</dc:creator>
    <dc:date>2017-07-01T23:21:40Z</dc:date>
    <item>
      <title>Join 4 tables using proc sql to check consistency across multiple datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Join-4-tables-using-proc-sql-to-check-consistency-across/m-p/372442#M65169</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;I suspect that subjects are erranously assigned to control (group&amp;amp;=1) vs exposure(group&amp;amp;=2)&amp;nbsp; in the sample data attached. Actual data is 5 times this sample. Loss in follow up is reflected in the data as well.&lt;/P&gt;&lt;P&gt;I'd like to test if groups are assigned to 1 and 2 consistently across four datasets (pretest=groupc, 7day follow up=group7d, 3mo follow-up=group3m and test among waitlisted=groupd). For that purpose, I thought, full join in proc sql joining all 4 datasets together on group and subj as key variables would help get better grasp of what happened.&lt;/P&gt;&lt;P&gt;I don't mind to get rid of joining on where most incomplete variable is null (where groupc=null). Coz it might not work in this unbalanced data due to loss in follow up over time. Using SAS 9.4.&lt;/P&gt;&lt;P&gt;The code didn't work. Log is shown below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; 
create table outer as 
select 	a.groupc,  a.subjc, 
	b.groupd,  b.subjd, 
	c.group7d, c.subj7d,
	d.group3m, d.subj3m
	from 	groupc  as a, 
		groupd  as b, 
		group7d as c, 
		group3m as d 
		full join groupc  on a.groupc =  b.groupd  and a.subjc  = c.subjd 
		full join groupc  on a.groupc =  c.group7d and a.subcj  = c.subj7d
		full join groupd  on b.groupd =  c.group7d and b.subjd  = c.subj7d
		full join group7d on c.group7d = d.group7d and c.subj7d = d.subj3m
        where a.group3m is null;
quit; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;617  proc sql;
618      create table outer as
619          select  a.groupc,  a.subjc,
620                  b.groupd,  b.subjd,
621                  c.group7d, c.subj7d,
622                  d.group3m, d.subj3m
623          from            groupc  as a,
624                          groupd  as b,
625                          group7d as c,
626                          group3m as d
627          full join groupc  on a.groupc =  b.groupd  and a.subjc  = c.subjd
628          full join groupc  on a.groupc =  c.group7d and a.subcj  = c.subj7d
629          full join groupd  on b.groupd =  c.group7d and b.subjd  = c.subj7d
630          full join group7d on c.group7d = d.group7d and c.subj7d = d.subj3m
631          where a.group3m is null;
ERROR: Column subjd could not be found in the table/view identified with the correlation name C.
ERROR: Column subjd could not be found in the table/view identified with the correlation name C.
ERROR: Column subjd could not be found in the table/view identified with the correlation name C.
ERROR: Column subjd could not be found in the table/view identified with the correlation name C.
ERROR: Column subjd could not be found in the table/view identified with the correlation name C.
ERROR: Column subcj could not be found in the table/view identified with the correlation name A.
ERROR: Column subcj could not be found in the table/view identified with the correlation name A.
ERROR: Column subcj could not be found in the table/view identified with the correlation name A.
ERROR: Column subcj could not be found in the table/view identified with the correlation name A.
ERROR: Column group7d could not be found in the table/view identified with the correlation name D.
ERROR: Column group7d could not be found in the table/view identified with the correlation name D.
ERROR: Column group3m could not be found in the table/view identified with the correlation name A.
ERROR: Expression using equals (=) has components that are of different data types.
632  quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Thank you very much for your time.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export data=groupc
outfile="\groupc.csv"
dbms=csv;
proc export data=groupd
outfile="\groupd.csv"
dbms=csv;
proc export data=group7d
outfile="\group7d.csv"
dbms=csv;
proc export data=group3m
outfile="\group3m.csv"
dbms=csv;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2017 19:05:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Join-4-tables-using-proc-sql-to-check-consistency-across/m-p/372442#M65169</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-07-01T19:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: Join 4 tables using proc sql to check consistency across multiple datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Join-4-tables-using-proc-sql-to-check-consistency-across/m-p/372445#M65170</link>
      <description>&lt;P&gt;Check which variables are in which dataset. Then re-formulate the join.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2017 21:15:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Join-4-tables-using-proc-sql-to-check-consistency-across/m-p/372445#M65170</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-01T21:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: Join 4 tables using proc sql to check consistency across multiple datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Join-4-tables-using-proc-sql-to-check-consistency-across/m-p/372464#M65171</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Thanks Kurt, i just corrected typo and misplaced variables. Now I get new error. Any suggestions as to what am I missing? Thanks again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; 
create table outer as 
	select 	a.groupc,  a.subjc, 
		b.groupd,  b.subjd, 
		c.group7d, c.subj7d,
		d.group3m, d.subj3m
	from 	groupc  as a, 
		groupd  as b, 
		group7d as c, 
		group3m as d 
	full join groupc  on a.groupc =  b.groupd  and a.subjc  = b.subjd 
	full join groupc  on a.groupc =  c.group7d and a.subjc  = c.subj7d
	full join groupd  on b.groupd =  c.group7d and b.subjd  = c.subj7d
	full join group7d on c.group7d = d.group3m and c.subj7d = d.subj3m&lt;BR /&gt;        where d.subj3m is null;
quit; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;New error in the log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: Correlated reference to column groupc is not contained within a subquery.
ERROR: Correlated reference to column groupd is not contained within a subquery.
ERROR: Correlated reference to column subjc is not contained within a subquery.
ERROR: Correlated reference to column subjd is not contained within a subquery.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2017 23:21:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Join-4-tables-using-proc-sql-to-check-consistency-across/m-p/372464#M65171</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-07-01T23:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: Join 4 tables using proc sql to check consistency across multiple datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Join-4-tables-using-proc-sql-to-check-consistency-across/m-p/372481#M65172</link>
      <description>&lt;P&gt;That's not how you write a FROM statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 01:46:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Join-4-tables-using-proc-sql-to-check-consistency-across/m-p/372481#M65172</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-02T01:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: Join 4 tables using proc sql to check consistency across multiple datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Join-4-tables-using-proc-sql-to-check-consistency-across/m-p/372659#M65175</link>
      <description>&lt;P&gt;Your from part, as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; noted, makes of course no sense at all; with regards to SQL syntax it is Vogon poetry.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is at least syntactically correct, but I have no clue about the semantic correctness:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; 
create table outer as 
select
  a.groupc,
  a.subjc,
  b.groupd,
  b.subjd, 
  c.group7d,
  c.subj7d,
  d.group3m,
  d.subj3m
from
  groupc as a
  full join groupd as b on a.groupc = b.groupd and a.subjc = b.subjd 
  full join group7d as c on a.groupc = c.group7d and a.subjc = c.subj7d
  full join group3m as d on c.group7d = d.group3m and c.subj7d = d.subj3m
where d.subj3m is null
;
quit; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Jul 2017 06:46:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Join-4-tables-using-proc-sql-to-check-consistency-across/m-p/372659#M65175</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-03T06:46:17Z</dc:date>
    </item>
  </channel>
</rss>

