Which PROC SQL query will remove duplicate values of MemberType from the query output, so that only the unique values are listed?

  1. proc sql nodup; select membertype from sasuser.frequentflyers;

  2. proc sql; select distinct(membertype) as MemberType from sasuser.frequentflyers;

  3. proc sql; select unique membertype from sasuser.frequentflyers group by membertype;

  4. proc sql; select distinct membertype from sasuser.frequentflyers;


Correct Option: D

AI Explanation

To answer this question, we need to understand how to remove duplicate values from a query output in PROC SQL.

Option A) proc sql nodup; select membertype from sasuser.frequentflyers; - This option is incorrect. The nodup keyword in PROC SQL is used to remove duplicate rows, not duplicate values within a single column. Therefore, this query will not remove duplicate values of MemberType.

Option B) proc sql; select distinct(membertype) as MemberType from sasuser.frequentflyers; - This option is incorrect. The distinct keyword is used to remove duplicate values from a column in the query output. This query will remove duplicate values of MemberType and provide only the unique values.

Option C) proc sql; select unique membertype from sasuser.frequentflyers group by membertype; - This option is incorrect. The unique keyword is not used in PROC SQL to remove duplicate values. This query will not remove duplicate values of MemberType.

Option D) proc sql; select distinct membertype from sasuser.frequentflyers; - This option is correct. The distinct keyword is used to remove duplicate values from a column in the query output. This query will remove duplicate values of MemberType and provide only the unique values.

The correct answer is Option D. This option is correct because it uses the distinct keyword to remove duplicate values of MemberType from the query output.

Find more quizzes: