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;
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;
I suspect use of the keyword - calculated - is optional in your example as both versions work without error.
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...
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.