- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 04-06-2009 06:10 AM
(7037 views)
hi all,
why is it not possible to order in subquery ??
proc sql;
create table test as
select *
from (select * from sashelp.class order by sex, age );
QUIT;
GR,
Herman
why is it not possible to order in subquery ??
proc sql;
create table test as
select *
from (select * from sashelp.class order by sex, age );
QUIT;
GR,
Herman
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I never heard of this one. It seems very weird. Cannot find any doc that hints of this restriction in use of sub-queries. I suggest that open a track to SAS support to get an explanation.
/Linus
/Linus
Data never sleeps
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
In this case your FROM Clause is a query expression
where the (query-expression) is an in-line view
According to the documentation
In-Line Views
The FROM clause can itself contain a query-expression that takes an optional table alias. This kind of nested query-expression is called an in-line view. An in-line view is any query-expression that would be valid in a CREATE VIEW statement. ......
Characteristics of in-line views include the following:
An in-line view is not assigned a permanent name, although it can take an alias.
An in-line view can be referred to only in the query in which it is defined. It
cannot be referenced in another query.
You cannot use an ORDER BY clause in an in-line view.....
For more information see
http://support.sas.com/documentation/cdl/en/proc/61895/PDF/default/proc.pdf
To fix the problem change your query to
proc sql;
create table test as
select *
from (select * from sashelp.class) order by sex, age ;
QUIT;
where the (query-expression) is an in-line view
According to the documentation
In-Line Views
The FROM clause can itself contain a query-expression that takes an optional table alias. This kind of nested query-expression is called an in-line view. An in-line view is any query-expression that would be valid in a CREATE VIEW statement. ......
Characteristics of in-line views include the following:
An in-line view is not assigned a permanent name, although it can take an alias.
An in-line view can be referred to only in the query in which it is defined. It
cannot be referenced in another query.
You cannot use an ORDER BY clause in an in-line view.....
For more information see
http://support.sas.com/documentation/cdl/en/proc/61895/PDF/default/proc.pdf
To fix the problem change your query to
proc sql;
create table test as
select *
from (select * from sashelp.class) order by sex, age ;
QUIT;