Reputation: 63
Could someone please help me with how SAS/SQL processes nested queries or subqueries. Would it do the inner select, "select sum(price) from MasterFile" only once or with each iteration of the outer query?
proc sql;
create table categorySpend as
select categoryid, sum (price) as CategoryRevenue, (select sum(price) from MasterFile)as TotalRevenue
from MasterFile
group by categoryid;
quit;
Upvotes: 2
Views: 87
Reputation: 9569
Probably the best way to get an idea of what's going on behind the scenes is to use the undocumented _method
and _tree
options in the proc sql
statement. For a very detailed write-up, this is a good source:
http://www2.sas.com/proceedings/sugi30/101-30.pdf
Upvotes: 4