DATA Step, Macro, Functions and more

Base Prep Ch.12 Quiz 6

Reply
Occasional Contributor
Posts: 19

Base Prep Ch.12 Quiz 6

[ Edited ]

#6 Assume the data set has 5 or more observations, what is the result of submitting the following program?

 

data a;

    obsn=5;

set b (keep=var1 var2) point=obsn;

    output;

    stop;

run;

 

a. an error

b. an empty data set

c. a continuous loop

d. a data set that contains one observation

 

My answer is D. but the answer key is A. according to the answer key: when you use the KEEP= data set option and the POINT= option with the OUTPUT and STOP statements, your program cannot write out a single observation.

 

I tested the codes in SAS and did generate one observation.

 

Can anyone verify my result for me?

Thanks.

 

Eric

Super User
Posts: 23,247

Re: Base Prep Ch.12 Quiz 6

Posted in reply to ericliuzh1

Which version of the study guide are you working with? Version 4?

Occasional Contributor
Posts: 19

Re: Base Prep Ch.12 Quiz 6

Yes, Version 4.

Super User
Posts: 6,628

Re: Base Prep Ch.12 Quiz 6

Posted in reply to ericliuzh1

It depends.  The program as posted will produce an error, because the variable name changed from OBSN to OBN.  But if the same name were to be used, you would get a single observation.

Occasional Contributor
Posts: 19

Re: Base Prep Ch.12 Quiz 6

Posted in reply to Astounding

Sorry, it was a typo. Same variable names.

Super User
Posts: 13,299

Re: Base Prep Ch.12 Quiz 6

Posted in reply to ericliuzh1

@ericliuzh1 wrote:

 

I tested the codes in SAS and did generate one observation.

 

 


Show the actual code you ran and the content of data set b.

I suspect @Astounding points to the difference between your code and the question.

Occasional Contributor
Posts: 19

Re: Base Prep Ch.12 Quiz 6

Will upload a snapshot tomorrow morning. Thanks.

Occasional Contributor
Posts: 19

Re: Base Prep Ch.12 Quiz 6

Attached is the quiz question.

Valued Guide
Posts: 516

Re: Base Prep Ch.12 Quiz 6

Posted in reply to ericliuzh1

Maybe the preparation guide is outdated. Using 9.4m3 a dataset with one observation was created:

 

12   data a;
13      obsn=5;
14
15      set sashelp.class(keep=Name Age) point=obsn;
16
17      output;
18      stop;
19   run;

NOTE: The data set WORK.A has 1 observations and 2 variables.
Super User
Posts: 23,247

Re: Base Prep Ch.12 Quiz 6

Posted in reply to andreas_lds
version 4 was just released, and that means it's sometimes a bit buggy Smiley Sad
Occasional Contributor
Posts: 19

Re: Base Prep Ch.12 Quiz 6

Agreed. Found another two errors. Now, I am confident with my answers. Thanks.

Super User
Super User
Posts: 7,932

Re: Base Prep Ch.12 Quiz 6

Posted in reply to ericliuzh1

Looks like you found a mistake in the quiz. Perhaps they will give you cookie it you report it?

 

Note that you also need to assume that the input dataset has at least the two variables listed in the KEEP= dataset option.

 


@ericliuzh1 wrote:

#6 Assume the data set has 5 or more observations, what is the result of submitting the following program?

 

data a;

    obsn=5;

set b (keep=var1 var2) point=obsn;

    output;

    stop;

run;

 

a. an error

b. an empty data set

c. a continuous loop

d. a data set that contains one observation

 

My answer is D. but the answer key is A. according to the answer key: when you use the KEEP= data set option and the POINT= option with the OUTPUT and STOP statements, your program cannot write out a single observation.

 

I tested the codes in SAS and did generate one observation.

 

Can anyone verify my result for me?

Thanks.

 

Eric


 

Ask a Question
Discussion stats
  • 11 replies
  • 119 views
  • 2 likes
  • 6 in conversation