SAS Advanced Programming for SAS 9

Here you have the best SAS Institue A00-212 practice exam questions

  • You have 33 total questions to study from
  • Each page has 5 questions, making a total of 7 pages
  • You can navigate through the pages using the buttons at the bottom
  • This questions were last updated on November 16, 2024
Question 1 of 33

The following SAS program is submitted:

%let a=cat;

%macro animal(a=frog);

%let a=bird;

%mend;

%animal(a=pig)

%put a is &a;

What is written to the SAS log?

    Correct Answer: B

    The statement %let a=cat; creates a global macro variable a with the value 'cat'. When the macro %animal(a=frog); is defined, it takes an optional parameter 'a', defaulting to 'frog' if not supplied. Inside this macro, %let a=bird; changes the local macro variable 'a' to 'bird'. However, when the macro is invoked as %animal(a=pig), the macro variable 'a' is locally set to 'pig' within the macro. The macro completes, but does not affect the global macro variable 'a'. Finally, when %put a is &a; is executed, it references the global macro variable 'a', which is 'cat', as declared at the beginning. Therefore, the correct output is 'a is cat'.

Question 2 of 33

Given the SAS data sets ONE and TWO:

The following SAS program is submitted:

Data combine;

Merge one two;

By id;

Run;

Which SQL procedure program procedures the same results?

    Correct Answer: C

    The provided SAS program merges the data sets ONE and TWO by the common variable ID, effectively performing an inner join. The correct SQL procedure to match this result is an inner join, which combines rows from both tables where the joining condition is met. Therefore, the SQL equivalent to the SAS merge command, ensuring that only matching IDs are included in the result, is the SQL inner join. This matches the description provided in option C.

Question 3 of 33

Given the following SAS data set ONE:

ONE -

REP COST -

SMITH 200 -

SMITH 400 -

JONES 100 -

SMITH 600 -

JONES 100 -

JONES 200 -

JONES 400 -

SMITH 800 -

JONES 100 -

JONES 300 -

The following SAS program is submitted:

proc sql;

select rep, avg(cost) as AVERAGE

from one

group by rep

having avg(cost) > (select avg(cost) from one);

quit;

Which one of the following reports is generated?

    Correct Answer: C

    To determine the correct result, let's examine the SQL code provided: `proc sql; select rep, avg(cost) as AVERAGE from one group by rep having avg(cost) > (select avg(cost) from one); quit;`. This code calculates the average cost for each representative and includes only those representatives whose average cost is greater than the overall average cost of all records. Calculating the overall average cost: (200 + 400 + 100 + 600 + 100 + 200 + 400 + 800 + 100 + 300) / 10 = 320. Next, we calculate the average cost per representative: SMITH: (200 + 400 + 600 + 800) / 4 = 500, JONES: (100 + 100 + 200 + 400 + 100 + 300) / 6 = 200. Since 500 (Smith's average) is greater than 320 (overall average), and 200 (Jones's average) is not, the correct report will show SMITH with an average of 500.

Question 4 of 33

Given the following SAS data set ONE:

ONE -

LEVEL AGE -

1 10

2 20

3 20

2 10

1 10

2 30

3 10

2 20

3 30

1 10

The following SAS program is submitted:

proc sql;

select level, max(age) as MAX

from one

group by level

having max(age) > (select avg(age) from one);

quit;

Which one of the following reports is generated?

    Correct Answer: B

    The given SAS program uses the PROC SQL procedure to select the highest age (MAX) for each level from data set ONE, then filters those levels where this maximum age is greater than the overall average age of the dataset. The overall average age in this dataset [(10+20+20+10+10+30+10+20+30+10)/10 = 17]. For LEVEL 2, the maximum age is 30, and for LEVEL 3, the maximum age is also 30. Both of these values are greater than the average age of 17. Therefore, the correct report that is generated is the one listing LEVEL 2 with MAX 30 and LEVEL 3 with MAX 30.

Question 5 of 33

This question will ask you to provide a segment of missing code.

The following SAS program submitted:

Which segment of code will successfully run an in-line view?

    Correct Answer: C

    The correct segment of code that will successfully run an in-line view must include a SELECT statement that creates a derived table. The correct syntax for an in-line view in SQL involves using the SELECT keyword, followed by the columns to be selected and any necessary grouping. Therefore, the correct answer is the one that includes the SELECT clause properly structured within parentheses. The correct code segment is: ( select dept, max(sal) as maxsal from EMP group by dept ) b.