BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
new510
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
kannand
Lapis Lazuli | Level 10

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...!!! 

Kannan Deivasigamani

View solution in original post

3 REPLIES 3
kannand
Lapis Lazuli | Level 10

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...!!! 

Kannan Deivasigamani
new510
Fluorite | Level 6
Thank you
Rikard
Fluorite | Level 6

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

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 12031 views
  • 1 like
  • 3 in conversation