I'm doing a join here where I'm basically taking all the columns from one table with a primary key and many other columns (too many to want to type out), then left joining a second table where all columns will be aggregated against the first one's primary key.
A simplified version is as follows:
SELECT a.*, COUNT(DISTINCT b.date), SUM(b.spend)
FROM table_1 a
LEFT JOIN table_2.b
ON a.cust_id = b.cust_id
GROUP BY a.* ;
I know that the above sytax works in SQL programs such as Teradata, but in SAS Enterprise Guide, using PROC SQL, I get the following error:
ERROR: * used in an illegal position.
ERROR: The following columns were not found in the contributing tables: a.
Basically, SAS doesn't seem to recognise the * when it is preceded by a alias.
Any suggestions? Thanks.
You have a period before the
b
alias. In addition, you cannotgroup by *
. Try this:This assumes that
cust_id
is unique intable_1
.