Hi,
Please anyone explain how the below answer is correct. This question is from a sas dump.
Given the SAS data set SASDATA.TWO:
SASDATA.TWO
XY
----
52
31
56
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.
Answer: A
You seem to be having errors in the code...
Given the SAS data set SASDATA.TWO:
SASDATA.TWO
XY
----
52
31
56
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;
In the set statement, a period "." is missing as your dataset name is SASDATA.TWO
Also, in the else statement, you are writing to sasdata & two however you have defined "sasdata.three" as the dataset name in your DATA step >> "
data sasuser.one two sasdata.three;
Hope this helps....Good Luck...!!!
You seem to be having errors in the code...
Given the SAS data set SASDATA.TWO:
SASDATA.TWO
XY
----
52
31
56
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;
In the set statement, a period "." is missing as your dataset name is SASDATA.TWO
Also, in the else statement, you are writing to sasdata & two however you have defined "sasdata.three" as the dataset name in your DATA step >> "
data sasuser.one two sasdata.three;
Hope this helps....Good Luck...!!!
The correct answer is not A. It is D ("The DATA step fails execution due to syntax errors."). The this due to the errors described in a previous reply. If submitting the code the SAS log looks like this:
56 data sasuser.one two sasdata.three;
57 set sasdata two;
ERROR: File WORK.SASDATA.DATA does not exist.
58 if x = 5 then output sasuser.one;
59 else output sasdata two;
-------
455
ERROR 455-185: Data set was not specified on the DATA statement.
60 run;
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.
WARNING: Data set WORK.TWO was not replaced because this step was stopped.
WARNING: The data set SASDATA.THREE 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.07 seconds
cpu time 0.04 seconds
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: