- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 02-04-2019 08:32 PM
(1010 views)
Is the following procedure legitimate? Please note that variable month is generated by the procedure itself. I can run it without any error reported, but not sure if the results are perfectly what I want.
proc sql;
create table want as
select name, intnx("month", date, 0, 'e') as month format yymmdd10., mean(var) as var_ave
from have
group by name, month
order by name, month;
quit;
5 REPLIES 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You need use the descriptive word "calculated", Try
proc sql;
create table want as
select name, intnx("month", date, 0, 'e') as month format yymmdd10., mean(var) as var_ave
from have
group by name, calculated month
order by name, calculated month;
quit;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It seems that the results do not change after adding it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Please post sample of your input and its output to demonstrate where it should differ
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I suspect use of the keyword - calculated - is optional in your example as both versions work without error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Since variable MONTH doesn't exist anywhere else, the keyword calculated can be omitted: it is obvious which MONTH you are referring to. Both queries yield the same result.
This calculated keyword is a powerful addition to ANSI SQL made by SAS.
Now if only SAS added other useful language extensions to SQL...