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 |
what is option year cuttoff in sas
Difference between sum function and using “+” operator?
How to convert HTML file into SAS dataset?
name the scheduler for scheduling job and explain the scheduler? : Sas-di
how many data types in sas? : Sas-administrator
If you use a symput in a data step, when and where can you use the macro variable? : sas-macro
name few built in sas transformation in DI studio ?
how can you sort the dataset having millions of OBS(instead of sort procedure?
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 different types of sas functions?
If you have a data set that contains 100 variables, but you need only five of those, what is the code to force SAS to use only those variable?
I Here clinical SAS training by Ramesh Azmeera is good. Is it confirm ?