Can we use where and having clauses in a single SAS program.
ex: proc sql;
select a,b,c from test
where state in 'KA'
and having <some condition>.
Is the above program run correctly, if not why ?
Answers were Sorted based on User's Feedback
Answer / rauthu
Yes, WHERE and HAVING can be used in single program. HAVING must be after GROUP by clause.
Example:
proc sql;
select make, model, avg(msrp) as avgmsrp, msrp
from sashelp.cars
where make ='Honda'
group by model
having avgmsrp < 100000;
quit;
| Is This Answer Correct ? | 9 Yes | 1 No |
Answer / rajasekaran
having statement should mentioned after group by statement only
proc sql;
select a,b,c from test
where state in 'KA'
group by xyz
and having <some condition>.
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / a.k.naidu
Having clause can be used only with 'group by'. Difference between 'where' and 'having' is that former works on variable level and latter works on observation level. 'having' works like second where condition on "grouped data"
| Is This Answer Correct ? | 2 Yes | 0 No |
Which is Best Institute for learning SAS BASE & SAS BI in Hyderabad? Can anyone suggest me ?
What is your favorite all time computer book? Why?
What is the difference between where and if statement?
what are the new features included in the new version of sas i.e., Sas 9.1.3? : Sas programming
What is the difference between INPUT and INFILE ?
% let A=3+4 what is result
What is the difference between an informat and a format. Name three informats or formats.
i have one dataset data l; input name: $ 25; cards; manoj is a good boy to krishna krishna is a god boy to malli malli is good boy to ramana ques: here i want "manoj" observations nubers
Hi... this is chandu, did MSc Microbiology, trying to get job in SAS tool, PLZ Tell me whether IT industries will give consider my education to gain a job....?
what are the differences between proc report and proc tabulate?
What is the maximum length of the macro variable?
What is the use of stop statement?