Obsidian | Level 7

## What is the correct option and why?

Given the SAS data set SASDATA TWO:
SASDATA TWO
XY
- -

- -
The following SAS program is submitted:

data sasuser.one two sasdata.three;
set sasdata two;
if x = 5 then output sasuser.one;
else output sasdata two;
run;

What is the result?

A. data set SASUSER.ONE has 5 observations
data set SASUSER. TWO has 5 observations
data set WORK. OTHER has 3 observations
B. data set SASUSER.ONE has 2 observations
data set SASUSER. TWO has 2 observations
data set WORK.OTHER has 1 observations
C. data set SASUSER.ONE has 2 observations
data set SASUSER. TWO has 2 observations
data set WORK.OTHER has 5 observations
D. No data sets are output.
The DATA step fails execution due to syntax errors.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User

## Re: What is the correct option and why?

I would think in general without knowing what the input (or inputs) are then option D is going to be the only one you can be certain is the answer.  The other answers depend on what is in the input data.

Let's go through them one by one:

A. data set SASUSER.ONE has 5 observations, data set SASUSER. TWO has 5 observations,
data set WORK. OTHER has 3 observations

For that to happen the data statement would need to be:

``data sasuser.one sasuser.two other ;``

So that there are 3 output datasets.  And the OUTPUT statements would need to either not mention any datasets (so that the observations is written to all of them) or only lists one or more of those datasets listed in the DATA statement.  So A is impossible given the OUTPUT statements even if the DATA statement was fixed.

B. data set SASUSER.ONE has 2 observations, data set SASUSER. TWO has 2 observations, data set WORK.OTHER has 1 observations

This seems to have the same problem.

C. data set SASUSER.ONE has 2 observations, data set SASUSER. TWO has 2 observations, data set WORK.OTHER has 5 observations

This seems to have the same problem.

D. No data sets are output. The DATA step fails execution due to syntax errors.

This one is true because the dataset names listed on the OUTPUT statements do not match the dataset names listed on the DATA statement.  Which is a syntax error and will cause the data step to not run.

17 REPLIES 17
Diamond | Level 26

## Re: What is the correct option and why?

@Nipun22 wrote:

Given the SAS data set SASDATA TWO:

Invalid name for a data set, it cannot have a space in it. So ERROR right there. Or is that just a typo? Questions like this cannot have typos or you get syntax errors that weren't intended by the questioner, and we can't give a meaningful answer.

But please follow these instructions to share the data set with us (and no other way is acceptable).

If you want to know what SAS will do, run the code yourself, don't ask us, SAS will tell you definitively what happens.

--
Paige Miller
Super User

## Re: What is the correct option and why?

As shown that code cannot run.

First because the two input datasets, WORK.SASDATA and WORK.TWO do not exist.

Second because the dataset WORK.SASDATA listed on the OUTPUT statement is not listed on the DATA statement.

```1    data sasuser.one two sasdata.three;
2    set sasdata two;
ERROR: File WORK.SASDATA.DATA does not exist.
ERROR: File WORK.TWO.DATA does not exist.
3    if x = 5 then output sasuser.one;
4    else output sasdata two;
-------
455
ERROR 455-185: Data set was not specified on the DATA statement.

5    run;

ERROR: Libref SASDATA is not assigned.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set SASUSER.ONE may be incomplete.  When this step was stopped there were 0 observations and 1 variables.
WARNING: Data set SASUSER.ONE was not replaced because this step was stopped.
WARNING: The data set WORK.TWO may be incomplete.  When this step was stopped there were 0 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time           0.95 seconds
cpu time            0.01 seconds
```

Obsidian | Level 7

## Re: What is the correct option and why?

that's the thing question has to be solved without the input dataset.

Super User

## Re: What is the correct option and why?

In an exam they may ask you to solve the question without input dataset. But for learning purposes, you can create an input dataset that matches the question, and run the code from the question, and explore the results.  And try different data and code than is in the question, to see how stuff works.

BASUG is hosting free webinars ! Check out our recordings of past webinars: https://www.basug.org/videos. Be sure to subscribe to our email list for notification of future BASUG events.
Obsidian | Level 7

## Re: What is the correct option and why?

yes exactly i found this question on a website and can be a SAS Certification question

Diamond | Level 26

## Re: What is the correct option and why?

Ok, then the problem was so poorly stated by whoever made it up, that the only logical answer is D, the data step fails to execute (as explained by @Tom ).

--
Paige Miller
Super User

## Re: What is the correct option and why?

The only answer I can give you: forget this website as a resource for exam preparation.

Obsidian | Level 7

## Re: What is the correct option and why?

what's your suggestions then? how should i prepare? and what if i find doubts in the online dumps?
Super User

## Re: What is the correct option and why?

When you have questions about specific points, bring them here.

Hint: there might be a reason why good preparations are not free (as in beer).

Creating a bunch of good and valid exam questions takes work. The one you showed here is simply crap. From where did you get it?

Super User

## Re: What is the correct option and why?

The very first statement on that "page" or whatever that image comes from is just plain wrong.

It says "Given the data set SASDATA TWO"

That is an invalid name for a data set. The name could be SASDATATWO, SASDATA_TWO or even "SASDATA TWO"N but not as presented. And that same error is repeated in multiple places.

With that introduction I would say that the source of this question is unreliable and would not trust the answers for any question as the foundation information they are presenting is wrong.

I have to assume that your image is as presented. If the space appeared in only one place I might believe it is a typo but there is absolutely not way that code could write any observations to SASUSER.TWO as the exact characters SASUSER.TWO do not appear anywhere in the shown code.

@Nipun22 wrote:

yes exactly i found this question on a website and can be a SAS Certification question

Diamond | Level 26

## Re: What is the correct option and why?

Same question was asked 9 years ago in the SAS communities.

https://communities.sas.com/t5/SAS-Programming/sas-base-question/td-p/237111

And here's the same question on Flash Cards (but with different data)

https://quizlet.com/413354973/all-sas-questions-216-flash-cards/

--
Paige Miller
Obsidian | Level 7

## Re: What is the correct option and why?

how did you find this?

by searching the content of the questions?

Super User

## Re: What is the correct option and why?

@Nipun22 wrote:

how did you find this?

by searching the content of the questions?

Google "Given the SAS data set SASDATA TWO:"

And there are dozens of places that someone (or a bunch of bots) have copied the exact same stuff.

Super User

## Re: What is the correct option and why?

I would think in general without knowing what the input (or inputs) are then option D is going to be the only one you can be certain is the answer.  The other answers depend on what is in the input data.

Let's go through them one by one:

A. data set SASUSER.ONE has 5 observations, data set SASUSER. TWO has 5 observations,
data set WORK. OTHER has 3 observations

For that to happen the data statement would need to be:

``data sasuser.one sasuser.two other ;``

So that there are 3 output datasets.  And the OUTPUT statements would need to either not mention any datasets (so that the observations is written to all of them) or only lists one or more of those datasets listed in the DATA statement.  So A is impossible given the OUTPUT statements even if the DATA statement was fixed.

B. data set SASUSER.ONE has 2 observations, data set SASUSER. TWO has 2 observations, data set WORK.OTHER has 1 observations

This seems to have the same problem.

C. data set SASUSER.ONE has 2 observations, data set SASUSER. TWO has 2 observations, data set WORK.OTHER has 5 observations

This seems to have the same problem.

D. No data sets are output. The DATA step fails execution due to syntax errors.

This one is true because the dataset names listed on the OUTPUT statements do not match the dataset names listed on the DATA statement.  Which is a syntax error and will cause the data step to not run.

Discussion stats
• 17 replies
• 1091 views
• 8 likes
• 6 in conversation