sas

31
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); 1

description

questions

Transcript of sas

Page 1: sas

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.) 5b.) 8c.) 12d.) Syntax Error

Answer: c

4.) PROC SORT data = lib.temp out = temp2;

By subjid;Run;In which library temp2 is made?

a.) WORKb.) SASUSERc.) LIBd.) SYNTAX ERROR

Answer: a5.) options obs = 500;

Data TEMP;Set test(firstobs = 75);

Run; What will be the number of observations in temp dataset?

a.) 424b.) 425c.) 500d.) 75e.) 426

Answer : e

1

Page 2: sas

6.) PROC SORT data = temp; BY Descending JOBCODE SALARY;

RUN;

Temp DATASET

JOBCODE SALARY AGEX1 100 20X2 100 10X2 200 20A1 100 10A2 200 10A2 200 40

What will be the output??

Answer: Temp DATASET

JOBCODE SALARY AGEX2 100 10X2 200 20X1 100 20A2 200 10A2 200 40A1 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 SALARY AGEA1 100 10A2 200 10A2 200 40X1 100 20X2 200 20X2 100 10

8.) DATA TEMP; MERGE X1 X2;

BY ID;RUN;

2

Page 3: sas

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

X1 DATASET X2 DATASET

ID NAME ID CLASS1 ANKUR 1 A2 VIJAY 1 B

2 B2 A

Answer: 3 variables and 4 observations

9.) DATA TEMP;

MISSING CODERUN;

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.) Ankurb.) Ankc.) 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

3

Page 4: sas

b.) In dataset _null_c.) Syntax errord.) Log

Answer: d

12.) What is true about _ERROR_ variable?a.) Can be used in assignments/calculation in datastep.b.) This variable appears in output datasetc.) Will have values “YES” or “NO”d.) Will have values “TRUE” or “FALSE”

Answer: a13.) 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.) DATETIMEb.) TIMEc.) DATEd.) 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= ‘13MAR2000’d;RUN;What is stored in x?

a.) 13MAR2000b.) Corresponds to days from 01 Jan 1960: 14682c.) 13/03/2000d.) 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’)03132000data temp;

infile ‘asa’;input date : MMDDYY10.;

run;

What will be stored in date?a.) 01022000b.) 02FEB2000

4

Page 5: sas

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.) 7b.) 5c.) 6d.) 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.5e.) 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 = ‘13MAR2000’d;format dat WEEKDATE.;

run;

What will be the value of dat in output dataset?a.) 13MAR2000 b.) Monday, March 13, 2000c.) Mon, March 13, 2000d.)14682 (nmber of days from 1st jan 1960)

Answer: b

22.) data temp;set x;

run;

5

Page 6: sas

“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.) 2b.) 1c.) 3d.) 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,,20RAJU,SHARMA,24DATA temp;

Infile ‘abc’ dsd;Input FNAME $ LNAME $ AGE;

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

a.) ‘,’b.) blank character valuec.) ‘SHARMA’d.) syntax error

Answer: b

26.) data temp;

6

Page 7: sas

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.) 2b.) 5c.) 7d.) 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.) 5b.) 20c.) 100d.) 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/2000b.) 31/11/2000c.) 31NOV2000e.) 01NOVEMBER2000

Answer: c

31.) Why PROC FSLIST is used?a.) to write to an external file

7

Page 8: sas

b.) to read from an external filec.) to sort by dated.) 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 NAMEB.) NAME IDC.) ID NAME CLASS AGED.) Syntax error

Answer: b

34.) data a;do X=1 to 3 ;input ID NAME $ AGE;end;

datalines;01 vivek 2202 vital 2503 rajes 20;What will be the number of observations and variables in output dataset??

a.) 3 and 3b.) 1 and 3c.) 1 and 4d.) 3 and 1

Answer: c

8

Page 9: sas

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: a

36) Flat file structure is as below1----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,120b) 2c). (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 below1----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)02032000b) 14643, the number of days from jan 1st , 1960c) 1460000, the number of days from jan 1st , 1960d) 02/03/2000

Ans: b 38) The following code is submitted

data temp;x=14643;y=put(x,mmddyy10.);run;

9

Page 10: sas

What would be the attributes of variable Y in the dataset TEMP? a) Length of Y is $10.b)Length of Y is 10c) Length of Y is 8d)None

Ans: a39) 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 below1----5----10 dan 23 45bob 44 50sue 30 80mam 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) 30b) 44c) 40d) 55

Ans: c

41) Flat file structure is as below (Very good question)1----5----10 vital reddy 45

10

Page 11: sas

vijay 30sarma 40

The following code is submitted.

data temp;infile ‘file specification’;input x $ age;if age<=40;run;How many observations will be there in the TEMP dataset?a)3b)2c)zero observationsd)syntax error

Ans: a 42) The following code is submitted.

data temp;salary='20000';bonus=0.1*salary;run;

What would be the value of BONUS variable in the dataset TEMP?a)’2000’b)2000c).(period)d)blankAns: b

43) The following code is submitted.

data temp;salary=.;if salary=. then salary=100;bonus=10;salary=.;total=sum(salary,bonus);run;

What would be the value of TOTAL variable in the dataset TEMP?a)100b)110c)10d).(period)Ans: c

44) The descriptor portion of the dataset TEMP has the label of variable SALARY as ‘Actual salary’. which of the below code changes the label of the variable SALARY to ‘given’? a)

11

Page 12: sas

proc print data=temp label;label salary='given';run;

b)proc print data=temp label;label salary 'given';run;

c)proc print data=temp;label salary 'given';run;

d)proc print data=temp;label salary='given';run;

Ans: a

45) the dataset XYZ is as below

JOBCODEChem3

data xyz;set temp;if jobcode='CHEM3' then description='senior chemist';else description='unknown';run;

What is the value of DESCRIPTION variable in the TEMP dataset?a) senior chemistb) unknownc) senior d) blank characters

Ans: b

Tip: here we need to use UPCASE (jobcode) in if statement as the character comparison is case sensitive.

46) The TEMP dataset has the values of variables as belowX Y Z150 less than 200 and gt 100 300

which of the below code creates the dataset TEMP with above values in the variables X, Y, and Z.

a)data temp;x=150;if 100 le x le 200 then do;

12

Page 13: sas

y='less than 200 and gt 100'; z=300;end;else do; y='other values'; z=400;end;run;

b)data temp;x=150;if 100 le x le 200 then do; y='less than 200 and gt 100'; z=300;else do; y='other values'; z=400;end;run;

c)data temp;x=150;if 100 le x le 200 then y='less than 200 and gt 100'; z=300;

else do; y='other values'; z=400;end;run;

d) None

Ans: a

47) Flat file structure is as below1----5----10 23 44The following code is submitted.data temp;infile ‘file specification’;input @1 weight 2. @4 height 2.;run;

What is the value of HEIGHT variable in the TEMP dataset?a) . (period)b) Blankc) 44d) 23

48) Following code is submitted.data temp:

13

Page 14: sas

do i=1 to 3; do j=1 to 4; salary=salary+300; end;end;run;

how many observations will present in the dataset TEMP?a)1b)3c)2d)0

Ans: a

49) The dataset XYZ has 5000 observations. options obs=500;proc print data=xyz(firstobs=100 )run;options obs=max; proc means data=xyz(firstobs=500) run;

How many observations processed in each procedure?a) 401 in the proc print and 4501 in the proc meansb) 5000 in the proc print and 500 in the proc meansc) 500 in the proc print and 5000 in the proc meansd) 4501 in the proc print and 401 in the proc means

Ans: a

50) Which of the following code calculates the mean of variables var1, var2, var3, and var4.a) MEAN(var1-var4)b) MEAN(of var1-var4)c) MEAN(var1 var2 var3 var4)d) MEAN(var1)

Ans: b

51) Which of the following code creates the permanent dataset MYDATA from temporary dataset MYDATA? Libname out ‘sas-library’;

a) data MYDATA; set MYDATA; run;b) data MYDATA; set out.MYDATA; run;c) data out.MYDATA; set MYDATA; run;

14

Page 15: sas

d) none

Ans: c

52) See the code below filename rawdata1 ‘u3x2888.reddy.lib(reddy)’; libname rawdata2 ‘u3x2888.reddy.saslib’data temp;infile missing code;input x y;run;what should be inserted in place of missing code?a)rawdata2b)rawdata1c)filed)none

Ans: b

53) what is the procedure to print the data portion of the dataset?a)PROC MEANSb)PROC SQLc)PROC PRINTd)PROC CONTENTS

Ans: c

54) what is the procedure to see the descriptor portion of the dataset?a)PROC MEANSb)PROC SQLc)PROC PRINTd)PROC CONTENTS

Ans: d

55) The variable JOBCODE has length $5 in the dataset TEMP. The same variable present in the dataset TEMP1 and has length $7.data temp2;set temp temp1;run;

what would be the length of the variable JOBCODE in the dataset TEMP2?

a) 5b) 7c) we can’t see the length as data set won’t be created due to errors.d) None

Ans: a

Tip: whenever we are concatenating the datasets which are having the same variable names but having the difference in the attributes like

15

Page 16: sas

Label, length etc.. will be taken from the first dataset that has occurred in the SET statement. Here it is TEMP dataset.

56) one question on using same variable in the ID and BY statement of PROC PRINT.

57) What will be the value of variable b in the log when following datastep is submitted? Today’s date is 31DEC2004;Data _NULL_; a=month(today()); b=put(a,date9.); put b;run;

a) 13JAN1960;b) syntax errorc) 31DEC2004d) 12

Ans:a

58) Data a has 12 observations and one variable Date as following.Date_________________________________________________01/01/200402/01/200403/02/200404/01/200405/01/200406/01/200407/01/200408/01/200409/01/200410/01/200411/01/200412/01/2004How many observations will be there dataset b if the following datastep is submitted?Data b; Set a; Temp = qtr(input(Date,mmddyy10.));

If Temp LE 3; RUN;

A) 3B) 5C) 9D) 6

Ans: D

59) What will be the length of variable LEN when the following code is submitted?

Data temp; A = ‘I am Bond, James Bond’;

16

Page 17: sas

LEN=SCAN(A,3);Run;

a) 4b) 20c) 8d) 200

Ans: d

60) What will be the value of variable LEN when the following code is submitted?Date temp; A=’I was Bond, A real Bond’; LEN=SUBSTR(A,6,4);Run;

a) 4b) 23c) 1d) 200

Ans: b

Note: Whenever a variable is created by assigning the value returned by the SCAN function, Its length is always $200 ( If it is not set explicitly using length statement). Similarly when a variable is created by assigning the value returned by the SUBSTR function, Its length is same as the source string no matter how many character did you cut from the original string. TRANWRD and COMPBL are the other two functions which return the value of length 200.

61) How many observations will be there in output dataset temp? data temp; x=4; if x=5 then do; y=2; output; end;run;

a) 1b) 2c) 0d) 3

Ans: c

62) Which variables will be present in dataset FINAL; data FINAL; set TRY1(KEEP= NUM1 NUM2 NUM3 NUM4)

17

Page 18: sas

TRY2(KEEP= NUM5 NUM6 NUM7 NUM8); DROP NUM2 NUM4 NUM7; KEEP NUM1 NUM3;RUN;

A) NUM1 NUM3 NUM5 NUM6 NUM8.B) NUM1 NUM3;C) Syntax Error.D) Warning in the log.

Ans:b

63) A datasetSEX_______CITYCODE__________JOBM NY WERF NY WERM WD RESM WD RESM SD EDM WF ED

What will be the correct code to get a cross frequency table as following?

The FREQ Procedure

Table of SEX by CITYCODE

SEX CITYCODE

Frequency‚ Percent ‚ Row Pct ‚ Col Pct ‚NY ‚SD ‚WD ‚WF ‚ Total ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ F ‚ 1 ‚ 0 ‚ 1 ‚ 0 ‚ 2 ‚ 16.67 ‚ 0.00 ‚ 16.67 ‚ 0.00 ‚ 33.33 ‚ 50.00 ‚ 0.00 ‚ 50.00 ‚ 0.00 ‚ ‚ 50.00 ‚ 0.00 ‚ 50.00 ‚ 0.00 ‚ ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ M ‚ 1 ‚ 1 ‚ 1 ‚ 1 ‚ 4 ‚ 16.67 ‚ 16.67 ‚ 16.67 ‚ 16.67 ‚ 66.67 ‚ 25.00 ‚ 25.00 ‚ 25.00 ‚ 25.00 ‚ ‚ 50.00 ‚ 100.00 ‚ 50.00 ‚ 100.00 ‚ ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ Total 2 1 2 1 6

33.33 16.67 33.33 16.67 100.00

a) PROC FREQ DATA=A; TABLES SEX*CITYCODE;

RUN;b) PROC FREQ DATA=A; TABLES SEX CITYCODE;

RUN;c) PROC FREQ DATA=A; TABLES SEX, CITYCODE; RUN;d) PROC FREQ DATA=A; VAR SEX CITYCODE; RUN; Ans: a

18

Page 19: sas

Suggestions:

1.) Please Go Through Programming Essentials I And II before appearing In Exam.

2.) Practice well to differentiate between the cases of Syntax Error and Missing value. This will help you achieving good score in Handling Errors.

Jan30-06

1.Raw data file given is----|----01012000

data temp; infile 'file'; input date mmddyy10.; if date='01012000'd then EVENT='January 1st'.run;

What is the value of EVENT in the dataset?a) January 1stb) '' (blank character value)c) no value as there is a syntax error in the datastepd) 01012000

ans c) as date constant uses ddmmmyyyy format i.e. date='01jan2000'd is the correct option here.

2. Array name related conceptual question

3. data temp; infile 'file'; input relation $ @; if relation='children' then

input sex $54; else if relation='parent' then input profession $; input Age;run;

how many records from infile will be read for a record in the dataset?

19

Page 20: sas

a) 0 b) 1c) 2d) 3

ans 1

4. data temp; infile 'file'; retain address {12}; array address {12} address1-address12;run;how many observations??a) 0b) 1c) 2d) 3

ans a (syntax error - error in retain statement)

5. proc sort data=temp; by style; run; proc print data=temp; <insert statements here for the exhibit shown> run;

Style Condo Bedrooms 50.158

Baths 12.225 Ranch Bedrooms 25.212

Baths 2.22 Split Bedrooms 124.55

Baths 120.22

a) id style;by style;var style bedrooms baths price;

b) id style

ans a

6. What should be the code for the exhibit shown below:

20

Page 21: sas

proc report data=temp;columns style bedrooms baths price;

<insert code>;run;(Dataset is also shown and the values of price in the exhibit is not mean)

Style Price Condo Bedrooms 50.158

Baths 12.225 Ranch Bedrooms 25.212

Baths 2.22 Split Bedrooms 124.55

Baths 120.22

a) define style/display width=9; define price/sum width=9;b) define style/display width=9; define price/mean width=9;

ans a

7. which statement creates grandtotal of cost?

a) grandtot=grandtot+cost;b) retain grandtot=0; grandtot=sum(grandtot, cost);c) retain grandtot;

ans b

8. Theory question related to SUM statement (not sum function)which is true for the SUM statement?a) SUM function is used in conjunctionb) it creates an accumulator variable

9. Question on PROC REPORT which uses mean of Price (given in the exhibit)- verify the values of price in dataset with the exhibit to identify the statistics used.

10. which option limits the decimals for standard deviation in the proc below to 2 decimalsproc means data=temp mean std max;run;a) maxdec=2b) format std 7.2c) maxdec= 7.2

21

Page 22: sas

ans a

11. data temp; jobcode='FA'

jobcategory='1';jobcode=jobcode||jobcategory;

run;what wud be value of jobcodeans FA

12. data temp;str='London, England';str2=substr(str, 1, 8);str3=str2||'England';

run;value of str3? a) London, England b) England c) London, Englandans a

13. Usage of Display option in DEFINE statement in PROC REPORT.

14. Input file has ----|--$1,120

data temp;infile 'file';input @1 price;run;value of price?a) 1120b) $1,120c) 2d) .(missing)ans d

22

Page 23: sas

Base qns

Q1

first 0.0713second 0.0715third 0.0773

Dataset Bank has above data.What is the output of following code

data newbank; do i=1 to 3; set banks; cost+5000; end;run;

Ans: 1 observation n 4 variables

Q2 There are 5000 observations in NEW dataset.

How many observations would be processed by following codes?

options obs=500;proc print data=new (firstobs=100);run;options obs=max;proc means data=new (firstobs=500);run;

Ans:401 obs in Proc Print4501 obs in Proc Means

Q3

1. Which of the following statements is true when SAS encounters a syntax error in a DATA step?

 a.   The SAS log contains an explanation of the error.

 b.   The DATA step continues to execute and the resulting data set is complete.

 c.   The DATA step stops executing at the point of the error and the resulting data set contains observations up to that point.

 d.   A note appears in the SAS log indicating that the incorrect statement was saved to a SAS data set for further examination.

23

Page 24: sas

Q4

1. The following SAS program is submitted: 2. data work.accounting;3. length jobcode $ 12;4. set work.department;

run;

The Work.Department SAS data set contains a character variable named jobcode with a length of 5. Which of the following is the length of the variable jobcode in the output data set?

 a.   5

 b.   8

 c.   12

 d.   The value cannot be determined because the program fails to execute due to syntax errors.

Q5

What is the value stored in NUM after this code is submitted?data n2;input num 6.;

datalines;$1,234.5;run;

Ans: ‘.’

Q6

What is the value stored in variable THIRD after the following program is submitted?

data n3;first='FA';second='1';third=first||second;run;

Ans: FA1

Q7

1. Which one of the following statements is true when SAS encounters a data error?

24

Page 25: sas

 a.   The execution phase is stopped, and a system abend occurs.

 b.   A missing value is assigned to the appropriate variable, and execution continues.

 c.   The execution phase is stopped, and a SAS data set is created with zero observations.

 d.   A missing value is assigned to the appropriate variable, and execution stops at that point.

Q8

How many records are there in the dataset when following code is submitted?

data n4;input name $ age sales;datalines;steve randall 45 5000david shepherd 57 6000russell tiffin 38 7000simon taufel 32 4000;if age le 50;run;

Ans4 observations 3 variables

Q9What is the value stored in NDATE when this code is executed?

data n5;dy=23;mn=3;yr=2000;ndate=mdy(mn,dy,yr);run;

Ans14692 (SAS equivalent of 23-MAR-2000)

Q10. What will be the value printed when following FORMAT is applied to Marks of 50.5. Dataset is SCORES, var is Marks which holds marks.

proc format;value rslt 1-50='Fail' 51-100='Pass';run;

proc print data=scores;format mark rslt.;run;Ans : 50.5

25