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 the order of evaluation of the following operators + - * / ** () ???
How to limit decimal places for variable using proc means?
I use NOCUM/NOPERCENT option in the tables statement like this Proc freq data = deepak; tables x y /nocum nopercent; run; Here I get nopercent and nocum in the output only for variables x and y. How do i do it for all variables? Deepak
How would you determine the number of missing or nonmissing values in computations?
what is the difference between SET and MERGE?
What are the different servers in sas? : sas-grid-administration
Where do the database management systems store data and how do u import them.
firstobs and obs are working only option wise,but we are using infile statement with firstobs and obs in a statement wise? so firstobs,obs working at options and statemnts or not?
Which command is used to save logs in the external file?
What is univariate n where it can be used n how...?
Describe the function and utility of the most difficult SAS macro that you have written?
how do you debug and test your sas programs? : Sas programming