DATA Step, Macro, Functions and more

sas base question

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

sas base question

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


Accepted Solutions
Solution
‎12-01-2015 09:19 AM
Regular Contributor
Posts: 161

Re: sas base question

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


All Replies
Solution
‎12-01-2015 09:19 AM
Regular Contributor
Posts: 161

Re: sas base question

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
Occasional Contributor
Posts: 8

Re: sas base question

Thank you
Occasional Contributor
Posts: 7

Re: sas base question

[ Edited ]

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

 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 2715 views
  • 0 likes
  • 3 in conversation