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.
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.
@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.
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
that's the thing question has to be solved without the input dataset.
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.
yes exactly i found this question on a website and can be a SAS Certification question
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 ).
The only answer I can give you: forget this website as a resource for exam preparation.
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?
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
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/
how did you find this?
by searching the content of the questions?
@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.
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.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.