Base Sas code

Accepted Solution Solved
Reply
Occasional Contributor poo
Occasional Contributor
Posts: 10
Accepted Solution

Base Sas code

Could someone please explain me answer of this question? I am going for Base exam in few days.

The contents of the SAS data set named PERM.STUDENTS are listed below:

name age

Alfred 14

Alice13

Barbara 13

Carol 14

The following SAS program is submitted using the PERM.STUDENTS data set as

input:

Libnameperm 'SAS-date-library';

data students;

set perm.students;

file 'file-specification';

put name $15. @5 age 2.;

run

Which one of the following represents the values written to the output raw data file?

A. ----|----10---|----20---|----30


Alfred 14

Alice 13

Barbara 13

Carol 14

B. ----|----10---|----20---|----30


Alfr14

Alic13

Barb13a

Caro14

C. ----|----10---|----20---|----30

Alfr14ed

Alic13e

Barb13ara

Caro14l

D. ----|----10---|----20---|----30


Alfred 14

Alice 13

Barbara 13

Carol 14

Thanks

Poo


Accepted Solutions
Solution
‎09-08-2012 07:57 PM
Occasional Contributor poo
Occasional Contributor
Posts: 10

Re: Base Sas code

Tom Thanks for reply, I got the answer.

age variable has range of '2' so it is just replacing 5th and 6th place with it.

correct answer is B

View solution in original post


All Replies
Super User
Super User
Posts: 6,499

Re: Base Sas code

Think about what the PUT statement means and how it will be processed by SAS.  Then tell us which one you think is right and why.  Also why are the other ones wrong?


put name $15. @5 age 2.;

Also it helps to post the results with a fixed space font like Courier .

A.

----|----10---|----20---|----30

Alfred 14

Alice 13

Barbara 13

Carol 14

B.

----|----10---|----20---|----30

Alfr14

Alic13

Barb13a

Caro14


C.

----|----10---|----20---|----30

Alfr14ed

Alic13e

Barb13ara

Caro14l


D.

----|----10---|----20---|----30

Alfred 14

Alice 13

Barbara 13

Carol 14

Solution
‎09-08-2012 07:57 PM
Occasional Contributor poo
Occasional Contributor
Posts: 10

Re: Base Sas code

Tom Thanks for reply, I got the answer.

age variable has range of '2' so it is just replacing 5th and 6th place with it.

correct answer is B

Occasional Contributor poo
Occasional Contributor
Posts: 10

Re: Base Sas code

I have few more question on Base SAS, Could someone help me out  or Is there anyone who is going to take Base Exam soon who wants to discuss question with me. I can send them my email-id if they want to. I will appreciate  the help.

1-The following SAS program is submitted:

data work.test;

Author = 'Agatha Christie';

First = substr(scan(author,1,' ,'),1,1);

run;

Which one of the following is the length of the variable FIRST in the output dataset?

A. 1

B. 6

C. 15

D. 200

For me out put of First = substr(scan(author,1,' ,'),1,1) will be A . Lenth of output(A) will be 1 but this is not true.

2- The following SAS program is submitted:

data work.accounting;

set work.dept1 work.dept2;

run;

A character variable named JOBCODE is contained in both the WORK.DEPT1

and WORK.DEPT2 SAS data sets. The variable JOBCODE has a length of 5 in the

WORK.DEPT1 data set and a length of 7 in the WORK.DEPT2 data set.

Which one of the following is the length of the variable JOBCODE in the output

data set?

A. 5

B. 7

C. 8

D. 12

here we are concatenating two data sets so length of jobcode in final data set would be 7. Is it correct?

Occasional Contributor poo
Occasional Contributor
Posts: 10

Re: Base Sas code


Thanks for the Post Manish!

Occasional Contributor poo
Occasional Contributor
Posts: 10

Re: Base Sas code

Question-


A PROC DATATSETS is used as follows(assumption: all libraries are and datasets
are existing):

proc datasets library=mylib details;

copy out=rloc;
select scoredata;
delete tension ;
run;

Which statement below explains the operations above most correctly?

a.
It lists all SAS data files with file size and date modified in ‘mylib’ library
and makes a copy of ‘scoredata’ file in ‘rloc’ library and deletes ‘tension’
dataset..

b. It lists all SAS data files with file size and date modified in ‘mylib’
library and deletes ‘tension’ file from ‘rloc’ library.

c. It lists all SAS data files with file size and date modified in ‘mylib’
library and makes a copy of ‘scoredata’ file in ‘rloc’ library and also copies
the ‘scoredata’ file in ‘rloc’ library.

d. It lists all sas data files with file size and date modified in ‘mylib’
library and makes a copy of ‘scoredata’ file in ‘rloc’ library.

☑ This topic is SOLVED.

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

Discussion stats
  • 5 replies
  • 1466 views
  • 4 likes
  • 2 in conversation