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



Can we use where and having clauses in a single SAS program. ex: proc sql;     select ..

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

Can we use where and having clauses in a single SAS program. ex: proc sql;     select ..

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

Can we use where and having clauses in a single SAS program. ex: proc sql;     select ..

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

Can we use where and having clauses in a single SAS program. ex: proc sql;     select ..

Answer / santhosh

worng

Is This Answer Correct ?    1 Yes 7 No

Post New Answer

More SAS Interview Questions

Explain input and put function?

0 Answers  


What is the function of output statement in a SAS Program?

0 Answers  


How do you add a number to a macro variable?

2 Answers  


How to select the observations randomly from a SAS dataset

7 Answers   NTT Data,


How to create list output for cross-tabulations in proc freq?

0 Answers  






Describe the function and untility of the most difficult SAS macro that you have written.

0 Answers  


Suppose there is a SAS dataset with following values - Parent Child A B B C D E F G G H H I and so on….. This goes onto 1000s of observations/rows. Now how do we identify from this dataset Grandparents and Grandchildrens ?

5 Answers   American Express, Barclays,


How would you code a merge that will write the matches of both to one data set, the non-matches from the left-most data set to a second data set, and the non-matches of the right-most data set to a third data set.

10 Answers   Accenture,


explain about sas business intelligence? : Sas-bi

0 Answers  


Explain the difference between using drop = data set option in set and data statement?

0 Answers  


How you are maintaining sas programmes in your company...any specific version control software you are using? If so, tell me the name?

0 Answers   Accenture,


What is the difference between the proc sql and data step?

0 Answers  


Categories