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

Diff between proc sql merge and join?

1 Answers   HSBC, Sristek,


What is the maximum length of the macro variable? : sas-macro

0 Answers  


What is the difference between reading data from an external file and reading data from an existing data set?

0 Answers  


What is a pdv and what are its functions?

0 Answers  


If reading an external file to produce an external file, what is the shortcut to write that record without coding every single variable on the record?

7 Answers   Accenture,






how to delete the duplicate columns permanently in SQL

2 Answers   Satyam,


What statement do you code to tell SAS that it is to write to an external file? What statement do you code to write the record to the file?

2 Answers   Accenture,


If you’re not wanting any SAS output from a data step, how would you code the data statement to prevent SAS from producing a set?

8 Answers   Accenture,


Where do the database management systems store data and how do u import them.

2 Answers   L&T,


How will you assign all the variables of an dataset into a macro variable separated by a space? For example if a dataset has variables A,B,C. Assign them to a macro variable X as X=A B C

3 Answers   Accenture, Oracle,


what is PhaseIII, ODS, TLG, Macro and Proc in SAS

0 Answers  


How do dates work in sas?

0 Answers  


Categories