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 different between functions and procs that calculate the same simple descriptive statistics? : Sas programming
What does P-value signify about the statistical data?
Do you know the features of sas?
what cause the "error: connect:" and "error in the libname statement" when there weren't any such problems?
What procedure you used to calculate p-value?
2 Answers Accenture, Quintiles,
what is the difference between calculating the 'mean' using the mean function and proc means? : Sas programming
How do you add a number to a macro variable?
what kind of variables are collected in AE dataset?
3 Answers Accenture, Quintiles, SAS,
What is the difference between an informat and a format? Name three informats or formats.
Explain the main difference between the sas procedures and functions? : Sas-administrator
how to rearrange the data as our wish by using dataset block?
What are the difference between sas functions and procedures?