Hello,
I am very new to proc sql and currently trying to concatenate several very large tables.
I used the code:
proc sql; create table inptadm as select * from raw.inptadm2002 union select * from raw.inptadm2003 union select * from raw.inptadm2004 union select * from raw.inptadm2005 union select * from raw.inptadm2006 union select * from raw.inptadm2007 union select * from raw.inptadm2008 union select * from raw.inptadm2009 union select * from raw.inptadm2010 union select * from raw.inptadm2011 union select * from raw.inptadm2012 union select * from raw.inptadm2013 union select * from raw.inptadm2014 ; quit;
and examples of my tables look similar to these below
raw.inptadm2002
var1
var2
var3
var4
a
c
d
u
s
u
d
l
e
g
w
b
raw.inptadm2003
var1
var2
var3
var4
d
g
i
k
w
f
h
k
w
g
r
b
…
raw.inptadm2014
var1
var2
var3
var4
e
h
l
u
g
u
r
l
e
w
w
k
I want a new table like this:
var1
var2
var3
var4
a
c
d
u
s
u
d
l
e
g
w
b
d
g
i
k
w
f
h
k
w
g
r
b
…
e
h
l
u
g
u
r
l
e
w
w
k
I keep getting this error codes in my log similar to
WARNING: A table has been extended with null columns to perform the UNION set operation.
ERROR: Column 13 from the first contributor of UNION is not the same type as its counterpart from the second. ERROR: Column 15 from the first contributor of UNION is not the same type as its counterpart from the second. ERROR: Column 17 from the first contributor of UNION is not the same type as its counterpart from the second.
and I do not know what I am doing wrong.
I ran code similar to this in the past with no issue so I am not sure how to troubleshoot this problem.
______________________
Also, when I try to list the specific variables that I want in each table using the following code
proc sql; create table enrl as select enrolid, dtstart, dtend, AGE, AGEGRP, DOBYR, ENRMON, MSA, REGION, SEX, state from enroll2002 union select enrolid, dtstart, dtend, AGE, AGEGRP, DOBYR, ENRMON, MSA, REGION, SEX, state from enroll2003 union select enrolid, dtstart, dtend, AGE, AGEGRP, DOBYR, ENRMON, MSA, REGION, SEX, state from enroll2004 union select enrolid, dtstart, dtend, AGE, AGEGRP, DOBYR, ENRMON, MSA, REGION, SEX, state from enroll2005 union select enrolid, dtstart, dtend, AGE, AGEGRP, DOBYR, ENRMON, MSA, REGION, SEX, state from enroll2006 union select enrolid, dtstart, dtend, AGE, AGEGRP, DOBYR, ENRMON, MSA, REGION, SEX, state from enroll2007 union select enrolid, dtstart, dtend, AGE, AGEGRP, DOBYR, ENRMON, MSA, REGION, SEX, state from enroll2008 union select enrolid, dtstart, dtend, AGE, AGEGRP, DOBYR, ENRMON, MSA, REGION, SEX, state from enroll2009 union select enrolid, dtstart, dtend, AGE, AGEGRP, DOBYR, ENRMON, MSA, REGION, SEX, state from enroll2010 union select enrolid, dtstart, dtend, AGE, AGEGRP, DOBYR, ENRMON, MSA, REGION, SEX, state from enroll2011 union select enrolid, dtstart, dtend, AGE, AGEGRP, DOBYR, ENRMON, MSA, REGION, SEX, state from enroll2012 union select enrolid, dtstart, dtend, AGE, AGEGRP, DOBYR, ENRMON, MSA, REGION, SEX, state from enroll2013 union select enrolid, dtstart, dtend, AGE, AGEGRP, DOBYR, ENRMON, MSA, REGION, SEX, state from enroll2014 ; quit;
I also get these error messages:
ERROR: Ambiguous reference, column AGE is in more than one table. ERROR: Ambiguous reference, column AGEGRP is in more than one table. ERROR: Ambiguous reference, column DOBYR is in more than one table. ERROR: Ambiguous reference, column ENRMON is in more than one table. ERROR: Ambiguous reference, column MSA is in more than one table. ERROR: Ambiguous reference, column REGION is in more than one table. ERROR: Ambiguous reference, column SEX is in more than one table. ERROR: Ambiguous reference, column state is in more than one table.
... View more