## Base SAS certification exam question

Hi, Could anyone help me understand the logic behind the following question, before giving me the answer?

Given the SAS data set WORK.INPUT:

`Var1     Var2 `
` A        one`
`A        two`
` B        three`
` C        four`
` A        five `

The following SAS program is submitted:

`data WORK.ONE WORK.TWO; `
`set WORK.INPUT; `
`if Var1='A' then output WORK.ONE; `
`output;`
` run; `

How many observations will be in data set WORK.ONE?

1 ACCEPTED SOLUTION

Accepted Solutions  PGStats
Opal | Level 21

## Re: Base SAS certification exam question

The DATA statement announces that two datasets will be produced in the WORK library : ONE and TWO.

the OUTPUT WORK.ONE statement outputs Var1 and Var2 to dataset ONE, but only when Var1='A'

the OUTPUT statement outputs Var1 and Var2 to both datasets, whatever the value of Var1.

...

Do the counting PG

PG
31 REPLIES 31  PGStats
Opal | Level 21

## Re: Base SAS certification exam question

The DATA statement announces that two datasets will be produced in the WORK library : ONE and TWO.

the OUTPUT WORK.ONE statement outputs Var1 and Var2 to dataset ONE, but only when Var1='A'

the OUTPUT statement outputs Var1 and Var2 to both datasets, whatever the value of Var1.

...

Do the counting PG

PG

## Re: Base SAS certification exam question

Hi:

I agree with PGStats... do the counting...or write the program and run the program. Equally important for understanding how the logic works, after you figure out how many obs are in WORK.ONE, try to figure out how many obs will be in WORK.TWO, then try to figure out WHY the counts are different. As a help, here's the code that makes the dataset WORK.INPUT.

Then you should be able to code and test the rest.

cynthia

data work.input;

infile datalines;

input var1 \$ var2 \$;

return;

datalines;

A        one

A        two

B        three

C        four

A        five

;

run;

## Re: Base SAS certification exam question

Thanks, PGStats & Cynthia.

Here's another one:

The following SAS program is submitted:

data gt100;

set airplanes(keep = type mpg load);

run;

The program fails to execute due to syntax errors.

What is the cause of the syntax error?

A. MPG is not a numeric variable.

B. LOAD is not a variable in the data set GT100.

C. LOAD is not variable in the data set AIRPLANES.

D. LOAD must be defined prior to the SET statement.

Thanks in advance, ## Re: Base SAS certification exam question

Hi:

Nobody from the forum is going to be in the exam with you. Does the test question show you what variables are in WORK.AIRPLANES? You should be able to figure this one out, too.

cynthia

## Re: Base SAS certification exam question

Cynthia,

I am cracking a list of sample questions and cross-checking reliability of solutions given on the website. I have my answers with me but some of the online answers seem to be wrong.

Thanks

## Re: Base SAS certification exam question

If you have no information as to what variables are there in work.airplanes, the most probable answer can be option C  I guess. Because, The keep= option tries to access load variable to be used in later statements since it happened to be in SET statement. So, if load variable is not already defined in the airplanes dataset, the program would stop during execution.

## Re: Base SAS certification exam question

Looks like these questions are like those on most standardized tests, you should pick the BEST answer. Using the Sherlock Holmes method helps (if you eliminate the impossible ...)

That is don't get too nit-picky.

In this case you can eliminate three of the answers as being clearly wrong.

A Would just cause SAS to automatically convert characters values to numeric values.

B Is just nonsense because this data step is defining the data set GT100.

D Is very poorly worded as what do they mean by defining LOAD in the context of this simple data step?  The most normal meaning is say that they mean you should have defined it via a LENGTH or ATTRIB statement before referencing it in the KEEP= option of the SET statement?  But no matter how you interpret the meaning of this choice SAS does NOT require you to pre-define variables.

So you are left with C as the BEST answer.  That one is only wrong if you know that the option DKRICOND is set to WARN instead of ERROR.

## Re: Base SAS certification exam question

LOAD is not a variable in the data set GT100. Base SAS Certification Questions and answers can help me crack the exam

## Re: Base SAS certification exam question

Cynthia,

I am not sure if the code that you've given above would yield the same results as the code given in my original post.

My question says ' how many observations will be data set WORK.ONE? And if I run the count(as suggested by PGStats) then it is 8 observations of Var A that would go into WORK.ONE.

On the other hand,I did run the code that you gave, and what the DATALINES statement did was simply produced the same results as given in the code and total number of observation that the LOG gave were 5. So different results! thanks , anyways!

Gavy

## Re: Base SAS certification exam question

Gary:

My program will ONLY create WORK.INPUT. You would have needed to type in the *REST* of the program yourself. I said I was going to get you started. Clearly, since you already cut and pasted the question part of the program (with work.one and work.two), I didn't think I needed to retype that portion.

So you are correct, that WORK.INPUT has 5 observations. That is "given" in the statement of the problem. If you had typed and run the *REST* of the program you would have been able to verify your counting, as shown in the attached log, that WORK.ONE has 8 obs and WORK.TWO has 5 obs. WORK.ONE has the "extra" obs because of the "extra" output in the IF statement.

cynthia ## Re: Base SAS certification exam question

Hi,

IF (and it 's a big IF) any of the questions were wrong, they would be corrected immediately. But I am not aware of any of the sample questions being wrong. If you think the answer to a question is wrong, then write and run a program that shows it is wrong. You can send your program code and your log to certification@sas.com to report a possible problem with the question/answer.

I think it is safe to assume that the posted answers are correct. If you think an answer is wrong, then you need to figure out WHY or HOW the posted answer could be right and what about your approach led you to a different answer.

cynthia

## Re: Base SAS certification exam question

It would write 8 obs in work.one dataset.

First output statement would write 3 obs (where var1 =''A' and second output statement would write each of the obs's to both the output datasets.

thus total obs written to work.one dataset = 3+5 =8

8