sas base dumps

Upload: mahesh-kumar-joshi

Post on 30-Oct-2015

815 views

Category:

Documents


8 download

DESCRIPTION

SAS Base Dumps, sas 9, a00-211 dumps

TRANSCRIPT

Sample SAS certification Questions

Sample SAS certification Questions

(Questions asked in Base SAS certification exam)

Values and names may be different:

1.) Which ODS command closes the HTML file??

Answer: ODS HTML CLOSE;

2.) Which is the correct statement:

a.) ODS HTML FILE = file;

b.) ODS FILE HTML = file

c.) ODS FILE = file

d.) ODS HTML = file

Answer: a

3.)

data temp;

set lib1.x

lib2.y;

length jobcode $12.;

run;

What would be the length of Jobcode in temp?

a.) 5

b.) 8

c.) 12

d.) Syntax Error

Answer: c

4.)

PROC SORT data = lib.temp out = temp2;

By subjid;

Run;

In which library temp2 is made?

a.) WORK

b.) SASUSER

c.) LIB

d.) SYNTAX ERROR

Answer: a

5.) options obs = 500;

Data TEMP;

Set test(firstobs = 75);

Run;

What will be the number of observations in temp dataset?

a.) 424

b.) 425

c.) 500

d.) 75

e.) 426

Answer : e

6.) PROC SORT data = temp;

BY Descending JOBCODE SALARY;

RUN;

Temp DATASET

JOBCODE

SALARYAGE

X1

100

20

X2

100

10

X2

200

20

A1

100

10

A2

200

10

A2

200

40

What will be the output??

Answer:

Temp DATASET

JOBCODE

SALARYAGE

X2

100

10

X2

200

20

X1

100

20

A2

200

10

A2

200

40

A1

100

10

7.)

PROC SORT DATA = TEMP;

By Jobcode DESCENDING Salary;

RUN;

What will be the first observation? (Apply this on dataset created in last question)

Answer:

Temp DATASET

JOBCODE

SALARYAGE

A1

100

10

A2

200

10

A2

200

40

X1

100

20

X2

200

20

X2

100

10

8.)

DATA TEMP;

MERGE X1 X2;

BY ID;

RUN;

How many observations and variables will be there in temp dataset?

X1 DATASET

X2 DATASET

IDNAME

ID

CLASS

1ANKUR

1

A

2VIJAY

1

B

2

B

2

A

Answer: 3 variables and 4 observations

9.)

DATA TEMP;

MISSING CODE

RUN;

What is the correct missing code?

a.) Merge Test1 /*Test1 contains JOBCODE */

Test2(rename = (Jcode = JOBCODE));

b.) Merge Test1 /*Test1 contains JOBCODE */

Test2(rename = (JOBCODE = JCODE));

c.) Merge Test1 (rename = (Jcode = JOBCODE)) /*Test1 contains JOBCODE */

Test2;

d.) Merge Test1 /*Test1 contains JOBCODE */

Test2(rename Jcode = JOBCODE));

Answer: a

10.) data temp;

test = X;

select(test);

when(Y) Name = Ank;

when(X) Name = Ankur;

when(Z) Name = ;

end;

run;

What is the output?

a.) Ankur

b.) Ank

c.) Missing (character missing value)

d.) Ankur

Answer: Good Question. I would suggest you to try this question on your system. The answer is b. Its because during compilation time the length of variable Name is set as 3 (see the first case Y) and hence even if the case X is satisfied the output will still be Ank. 11.) data _null_;

put ankur;

run;

Where will the ouput(ankur) be written?

a.) In Last file opened

b.) In dataset _null_

c.) Syntax error

d.) Log

Answer: d12.) What is true about _ERROR_ variable?

a.) Can be used in assignments/calculation in datastep.

b.) This variable appears in output dataset

c.) Will have values YES or NO

d.) Will have values TRUE or FALSE

Answer: a

13.) What is true about array variables?

a.) They are temporary variables created in datastep.

b.) They are output in dataset.

c.) Can contain numeric and character values at same time.

d.) Cannot be used in assignment statement.

Answer: b

14.) What is the system option to print TIME in OUTPUT window?

a.) DATETIME

b.) TIME

c.) DATE

d.) SECOND

Answer: c

15.) PROC Report question on difference between display and across.

16.) PROC Report question on difference between group and order.

17.)

DATA TEMP;

X= 13MAR2000d;

RUN;

What is stored in x?

a.) 13MAR2000

b.) Corresponds to days from 01 Jan 1960: 14682

c.) 13/03/2000

d.) Corresponds to days from 01 Jan 1960: 135680

Answer: b (the choices mentioned in b and c points both were there. Hence I had to calculate the number of days from 01 Jan 1960. ( Although a rough idea will do. There was a digit difference between 2 options)

18.)

1----5----10---(data in file asa)

03132000

data temp;

infile asa;

input date : MMDDYY10.;

run;

What will be stored in date?

a.) 01022000

b.) 02FEB2000

c.) 14682(number of days from 1st jan 1960)

d.) 02 January

Answer: c (Note: the date is stored in dataset as SAS date)

19.)

data test;

n=1;

do while(n lt 6);

n+1;

end;

run;

What will be the value of n at the end of datastep?

a.) 7

b.) 5

c.) 6

d.) 8

Answer: c (Good Question again. This question will tell you that before marking any choice think twice. Actually it comes out of do while loop when n is 6 and will not execute the statement n+1;)

20.) GOOD QUESTIONProc Format;

Value ag 1-50 = less

51-100 = greater;

Run;

Data test;

X = 50.5;

Format x ag.;

Run;

What will be the output of dataset test?

a.) less

b.) greater

c.) great

d.) 50.5

e.) systax error

Answer: d ( I would suggest please try it on your PC and check for different values. Whenever SAS does not find a mapping for some value in the format it print the value as it is.)

21.)

data test;

dat = 13MAR2000d;

format dat WEEKDATE.;

run;

What will be the value of dat in output dataset?

a.) 13MAR2000

b.) Monday, March 13, 2000

c.) Mon, March 13, 2000

d.)14682 (nmber of days from 1st jan 1960)

Answer: b

22.) data temp;

set x;

run;

missing code

data test;

set y;

run;

What will be the missing code to reset the page number ?

a.) OPTIONS PAGENO = 1;

b.) OPTIONS RESET PAGENO = 1;

c.) OPTIONS RESET PAGENUMBER = 1;

d.) OPTIONS PAGENUMBER = 1;

Answer: a

23.)

DATA TEMP;

Infile filename;

Input ID $5 @;

If ID = RAMES then input Y $6 Z $10 @;

else ID = VIJAY then input R $2 @;

Input age 5.;

RUN;

How many lines are read from input file during one execution of dataset?

a.) 2

b.) 1

c.) 3

d.) 4

Answer: b (note only one execution not complete dataset)

24.) How to write comma separated file?

a.) FILE filename dsd = ,;

b.) FILE filename dlm = dsd = ,;

c.) FILE filename dlm = ,;

d.) FILE filename csv = ,;

Answer: c

25.)

1----5----10----15----(file abc)

RAM,,20

RAJU,SHARMA,24

DATA temp;

Infile abc dsd;

Input FNAME $ LNAME $ AGE;

RUN;

What will be the value of LNAME for 1st observation?

a.) ,

b.) blank character value

c.) SHARMA

d.) syntax error

Answer: b

26.)

data temp;

set test1(in = a) /* 2 observations*/

test2(in=b); /* 5 observations*/

if a and b;

run;

How many observations will be there in temp dataset?

a.) 2

b.) 5

c.) 7

d.) 0

Answer: 0 (Good question, repeated many times. Note a and b).

27.) data temp;

set test; /* 100 observations 20 for each ID*/

by ID;

if first,ID then name = RAJU;

else if ID = RAM then name = RAMU;

if last.ID;

run;

How many observations will be present in temp dataset?

a.) 5

b.) 20

c.) 100

d.) 0

Answer: a

28.) Question on PROC PRINT with BY statement;

29.)

libname temp abc.sds.as;

data temp.X1.

set sasuser.X2;

run;

Which is the correct statement??

a.) In datastep input is read from temporary location and output is written to temporary location.

b.) In datastep input is read from permanent location and output is written to temporary location.

c.) In datastep input is read from temporary location and output is written to permanent location.

d.) In datastep input is read from permanent location and output is written to permanent location.

Answer: d

30.) What is the output of DATE9. format?

a.)11/31/2000

b.) 31/11/2000

c.) 31NOV2000

e.) 01NOVEMBER2000

Answer: c

31.) Why PROC FSLIST is used?

a.) to write to an external file

b.) to read from an external file

c.) to sort by date

d.) not a valid statement

Answer: b

32.)

1----5----10----15----20 (filename = abc)

ankur

22

data temp;

infile file;

input name $1-10 age 15-16;

/*missing code*/

run;

What is the missing code to write ankur,22 to variable LA;

a.) LA = TRIM(name)||,||put(Age,2.);

b.) LA = name||,||put(Age,2.);

c.) LA = name|| ,||TRIM(put(Age,2.));

e.) LA = put(name)||,||put(Age,3.);

Answer: a 33.)

data temp;

merge test1(keep = ID)

test2(keep = ID NAME CLASS AGE);

by ID;

keep = ID NAME;

run;

Variables in output dataset?

A.) ID NAME

B.) NAME ID

C.) ID NAME CLASS AGE

D.) Syntax error

Answer: b

34.) data a;

do X=1 to 3 ;

input ID NAME $ AGE;

end;

datalines;

01 vivek 22

02 vital 25

03 rajes 20

;What will be the number of observations and variables in output dataset??

a.) 3 and 3

b.) 1 and 3

c.) 1 and 4

d.) 3 and 1

Answer: c

35) What informat should be used to read the date variable in the flat file having the values like 02NOV2003?

a)DATE9.

b)MMDDYY8.

c)MMDDYY10.

d) none

Answer: a36) Flat file structure is as below

1----5----10

$1,120

The following code is submitted.

data temp;

infile file specification;

input salary 5;

run;

What would be the value of SALARY in the dataset TEMP?

a)$1,120

b) 2

c). (period)

d) Blank value

Ans: b

Tip: Here the SAS goes to the 5th column and read the value. But if we specify the informat like SALARY 5. then there will be . In the SALARY variable. Please keep in mind that if there is any data error, SAS produces blank values to those variables(i.e . For numeric variables and blank for the character variables). SAS never stops execution when data error occurs.

37) Flat file structure is as below

1----5----10

02032000

The following code is submitted.

data temp;

infile file specification;

input date mmddyy10.;

run;

what is the value of date in the dataset TEMP?

a)02032000

b) 14643, the number of days from jan 1st , 1960

c) 1460000, the number of days from jan 1st , 1960

d) 02/03/2000

Ans: b

38) The following code is submitted

data temp;

x=14643;

y=put(x,mmddyy10.);

run;

What would be the attributes of variable Y in the dataset TEMP?

a) Length of Y is $10.

b) Length of Y is 10

c) Length of Y is 8

d) None

Ans: a

39) The following code is submitted

data temp;

length y $5;

x=4;

if x=4 then y='four';

else if x=7 then y='seven';

x=7;

run;

What would be the value of X and Y in the dataset temp?

a) X=4 and Y= seven

b) X=7 and Y=seven

c) X=7 and Y=four

d) X=4 and Y=four

Ans: c

40) Flat file structure is as below

1----5----10

dan 23 45

bob 44 50

sue 30 80

mam 40 50

The following code is submitted.

data temp;

infile file specification;

input x $ 1-3;

if x='sue' then input age 5-6;

else input height 8-9;

run;

what would be the value of variable AGE in the dataset TEMP when variable X has the value Sue?

a) 30

b) 44

c) 40

d) 55

Ans: c

41) Flat file structure is as below (Very good question)

1----5----10

vital reddy 45

vijay 30

sarma 40

The following code is submitted.

data temp;

infile file specification;

input x $ age;

if age