BookmarkSubscribeRSS Feed
xyxu
Quartz | Level 8

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
Shmuel
Garnet | Level 18

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;
xyxu
Quartz | Level 8
It seems that the results do not change after adding it?
Shmuel
Garnet | Level 18
Please post sample of your input and its output to demonstrate where it should differ
SASKiwi
Opal | Level 21

I suspect use of the keyword - calculated - is optional in your example as both versions work without error.

ChrisNZ
Tourmaline | Level 20

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...

 

 

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 466 views
  • 0 likes
  • 4 in conversation