Docsity

SAS Programming Concepts, Exams of Computer Science

Toggle sidebar
bg1
SAS BASE CERTIFICATION QUESTIONS & ANSWERS
c - Answers -Which of the following will select from a data set only those observations
for which the value of the variable Genre is SciFi, Western, or Classic?
a.where genre='SciFi' or 'Western' or 'Classic';
b.where genre is SciFi Western Classic;
c.where genre in ('SciFi', 'Western', 'Classic');
d.where genre in (SciFi, Western, Classic);
b - Answers -What happens when the following program is run?
proc sort data=black.book;
run;
proc print data=black.book;
var name age number;
where status='Single';
run;
a. The PROC PRINT step is successful, providing list in sorted order.
b. The PROC SORT generates an error in the log, the PROC PRINT step runs.
c. The PROC SORT step permanently sorts the data set.
d. The PROC SORT runs successfully, PROC PRINT generates errors
d - Answers -What usually happens when a syntax error is detected?
a. SAS continues to process the step, and the SAS log displays messages about the
error.
b. SAS continues to process the step.
c. SAS stops processing the step in which the error occurred, and the Output window
displays messages about the error.
d. SAS stops processing the step in which the error occurred, and the SAS log displays
messages about the error
a - Answers -What is the default length of the variable BALANCE?
Name Balance
Andrews 123.21
Smithy 92.31
Keeley 2812.23
Cist 981.99
a. 8
b. 32
c. 0
d. 16
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18

Partial preview of the text

Download SAS Programming Concepts and more Exams Computer Science in PDF only on Docsity!

SAS BASE CERTIFICATION QUESTIONS & ANSWERS

c - Answers -Which of the following will select from a data set only those observations for which the value of the variable Genre is SciFi, Western, or Classic? a.where genre='SciFi' or 'Western' or 'Classic'; b.where genre is SciFi Western Classic; c.where genre in ('SciFi', 'Western', 'Classic'); d.where genre in (SciFi, Western, Classic); b - Answers -What happens when the following program is run? proc sort data=black.book; run; proc print data=black.book; var name age number; where status='Single'; run; a. The PROC PRINT step is successful, providing list in sorted order. b. The PROC SORT generates an error in the log, the PROC PRINT step runs. c. The PROC SORT step permanently sorts the data set. d. The PROC SORT runs successfully, PROC PRINT generates errors d - Answers -What usually happens when a syntax error is detected? a. SAS continues to process the step, and the SAS log displays messages about the error. b. SAS continues to process the step. c. SAS stops processing the step in which the error occurred, and the Output window displays messages about the error. d. SAS stops processing the step in which the error occurred, and the SAS log displays messages about the error a - Answers -What is the default length of the variable BALANCE? Name Balance Andrews 123. Smithy 92. Keeley 2812. Cist 981. a. 8 b. 32 c. 0 d. 16

c - Answers -Which time span is used to interpret two-digit values if the YEARCUTOFF= option is set to 1969? a. 1969- b. 1969- c. 1969- d. 1870- e. 1970- b - Answers -What does the NOOBS option do in the PROC PRINT step? a. Relentlessly mocks you for being new to SAS. b. Removes the default Obs column from the output c. Prints only the the column titles with no data. d. Prints the data with no column titles. c - Answers -Which statement correctly accesses an Excel file? a.libname xldat 'C:\Excel\example.xlsx.Sheet1'; b.filename xldat 'C:\Excel\example.xlsx'; c.libname xldat 'C:\Excel\example.xlsx'; d.filename xldat 'C:\Excel\example.xlsx\Sheet1$'; j - Answers -The following format substitutes full names for initials. Identify the error(s). proc format lib=soil; value drvfmt; SS=Sam Smithie Smith JR=Jim Rollins ER=Elmer Richards run; a. the strings on the right of the equal sign need to have quotes. b. the strings on the left of the equal sign need to have quotes. c. the format needs to have a $ in front of the name d. semicolons should be after each line e. there should be no semicolon after the word drvfmt f. there should be a semicolon after the final format entry g. (a) and (b) h. (c) and (d) i. (e) and (f) j. (a), (b), (c), (e), and (f) k. all of the above l. none of the above

d. infile jobs obs=20; e. input jobs obs=20; a - Answers -What is not created in the compilation phase of the DATA step? a. the first observations b. the automatic variables N and ERROR c. the data set descriptor d. the program data vector d - Answers -Which of the following statements will process only the records above where Driver is SS? a. a or c b.if driver=SS c.if driver is SS d.if driver='SS' b - Answers -During the compilation phase, SAS checks each statement looking for syntax errors. Which of the following is not a syntax error? a. missing or invalid punctuation b. improper formats and incorrect values c. missing or misspelled keywords. d. invalid options or variable names c - Answers -How would you create a list report of an Excel sheet? a.data work.new; infile xldat.'Sheet1$'; input var1 var2 var3; run; proc print data=work.new; run; b.proc print data=xldat; sheet = 'Sheet1'; run; c.proc print data=xldat.'Sheet1$'n; run; d.proc print data=xldat.'Sheet1$'; run; d - Answers -When you run a SAS program to read in biographical information, an error occurs from the 3rd to the 20th records due to a change of format in the DoB column. What is the value of ERROR after the 17th record is read in? a. 0 b. 14 c. 3 d. 1 b - Answers -The DATA step will execute a. once for each phase of the DATA step.

b. once for each record in input file c. once for the data set d. once for each variable in the input statement f - Answers -The default statistics created using PROC MEANS i. n-count ii. mean iii. median iv. min v. max vi. standard deviation vii. range viii. Q ix. Q x. P xi. P a. iv, viii, iii, ix, v b. all of them are generated by default c. i, xi, x d. i, ii only e. none of the these (where is my z statistic...) f. i, ii, iv, v, vi g. ii only d - Answers -Using the ODS statements, how many different outputs (HTML, PDF, RTF, etc...) can be created at the same time? a. 3 b. 2 c. 1 d. As many as are needed d - Answers -If ODS is set to its default settings, what output is created by the following code? ods html file="c:/htmlout.html"; ods pdf file="c:/pdfout.pdf"; ods rtf file="c:/rtfout.rtf"; a. HTML, RTF, listing b. HTML, PDF c. RTF only d. HTML, PDF, RTF, Listing e. none, ODS is closed by default

d. Summary statistics are computed on BY-variable values a - Answers -You have a data set containing the following variables, which of them is a poor choice for PROC MEANS analysis a. emp id num b. bonus c. years employeed d. salary e. sick days a - Answers -What output does the following code produce? proc report data=employees nowd; column name yrsemp salary yrsales bonus; run; a. a list report that displays a row for each observation in the input data set and includes only the variables in the COLUMN statment. b. a list report that calculates the N (frequency) statistic for character variables. c. a list report ordered by values of the first variable in the COLUMN statement d. a summary report ordered by values of the first variable in the COLUMN statement. a - Answers -When you define an order variable in PROC REPORT a. all of the above b. none of the above c. you are unable to create a summary report d. PROC REPORT displays only the first occurrence of each order variable in sets of rows with duplicate order variables. e. the detail rows are ordered according to their formatted values a - Answers -By default, PROC FREQ creates tables of frequencies and percentages for which data set variables? a. both character and numeric variables b. numeric variables c. character variables d. none: you must always specify the variables. d - Answers -Consider the following code. data sandbox; set employees(keep=Name Weight Gender); by Gender; if first.gender then do; n=0;

avgWeight=0; end; n+1; avgWeight+Weight; if last.gender then do; avgWeight=avgWeight/n; output; end; run; Assuming the code runs without errors and employees starts with 200 observations, how many observations will be in sandbox? a. 0 b. 200 c. 1 d. 2 d - Answers -The data step executes a. once for each variable in the output data set b. continuously if you use the POINT= option and the STOP statement. c. until it encounters an OUTPUTstatement d. once for each observation in the input data set. c - Answers -Which statement correctly preserves the "date" variables in both data sets? a. merge employees sales; rename employees.date = dateHired sales.date=dateSold; b. merge employees (date=dateHired) sales (date=dateSold); c. merge employees sales (rename=(date=dateSold)); d. merge employees (rename date=dateHired) sales (rename date=dateSold); d - Answers -Which of the following can determine the length of a new variable? a. the length of the first value b. the assignment statement c. the LENGTH statement d. all of the above e. none of the above d - Answers -What variables are in sandbox when it is run?

c. The code has a syntax error. d. i, j e - Answers -Which array statement option(s) would only apply when creating new variables? a. length b. dimension c. initial values d. b and c e. a and c a - Answers -You have a variable FUNCODE which is 123M43S3 for one occurrence and 983F23G4 for another. The fourth character is the gender and age is the numbers in the 5th and 6th characters. What is used to assign AGE to the appropriate value? a. AGE=substr(funcode,5,2); b. AGE=scan(funcode,5); c. AGE=scan(funcode,5,2); d. AGE=substr(funcode,5); b - Answers -You have a set of variables Var1 Var2 Var3 Var4 Var5. Which function will calculate the mean? a. mean(var) b. mean(of var1-var5) c. mean(of var1,var5) d. mean(var1-var5) b - Answers -If you have a date variable (date) whose value is 01 January 2009 and were interested in determining the month value, what function would you use? a. month=mdy(date,'month'); b. month=month(date); c. month=today(date); d. month=qtr(date); c - Answers -How can you find out the dimensions of the array sales? a. The automatic macro variable &dimsales b. None of the these c. dim(sales)

d. dimensions(sales) a - Answers -What will the following output? data null; array i{2,3} (1 2 3 4 5 6); array j{6} (10 20 30 40 50 60); do k=3,1; total + i{2,k} - j{2k}; end; grandtotal = total + sum(of j{}); put grandtotal=; run; a. grandtotal= b. grandtotal=- c. grandtotal= d. - b - Answers -How many observations are in playground after the data step is run? data playground; do x=0 to 9; do y =0 to 9; if x in(1,3,5,7,9) then do; z=x*10+y; output; end; end; end; run; a. 0 b. 50 c. 100 d. 10 e. Can not determine from the output. a - Answers -Suppose that the YEARCUTOFF= system option is set to 1910. Which MDY function creates the date value for April 22, 2010. a. MDY(4,22,2010); b. MDY(22,4,10); c. MDY(4,22,10);

a. Julian dates b. Jewish holidays c. leap years d. time zones b - Answers -The following are the first lines of an input file. 123456789|123456789|123456789| Smith Joe 27 1892 81059 Franks Carl 24 2343 84060 Well Sam 32 4569 76182 Max Cori 21 1052 87231 Which piece of code reads the data without errors? a. data people; infile people.txt'; input @21 dob @8 first $ @1 last $ @16 dues; informat dues comma5.2; informat dob julian.; run; b. data people; infilepeople.txt'; input last $ first $ dues dob; informat dues comma4.2; informat dob julian.; run; c. data people; infile people.txt'; input @21 dob @8 first @1 last dues; informat dues comma5.2; informat dob julian.; run; d. data people; infilepeople.txt'; input last first dues dob; informat dues comma5.2; informat dob julian.; run; a - Answers -Consider the following data. Smith Joe 27 1892 81059 Franks Carl 24 2343 84060 Well Sam 32 4569 76182 Max Cori 21 1052 87231 The following versions of the same data are missing some values. Which file should be read in with the MISSOVER option? a. Smith Joe 27 1892Franks Carl 24 2343 84060Well Sam 32 4569 76182Max Cori 21 1052 87231 b. Smith Joe 27 1892 81059Franks Carl 24 2343 84060Well Sam 32 4569 76182Max Cori 21 87231 c. Smith Joe 27 1892 81059Franks Carl 2343 84060Well Sam 32 4569 76182Max Cori 21 1052 87231 d.

Smith Joe 27 1892 81059Franks Carl 24 2343 84060Well 32 4569 76182Max Cori 21 1052 87231 d - Answers -The min width of a the TIMEw. informat is a. 7 b. 4 c. 6 d. 5 d - Answers -SAS date values are the number of days since which date? a. Jan 1, 1900 b. Jan 1, 1950 c. Jan 1, 1901 d. Jan 1, 1960 b - Answers -Which informat could be use to read the date value 01MAR91? a. mmddyy6. b. date7. c. weekdate6. d. date9. d - Answers -The advantage of storing date and time data as numeric data comes in the form that a. they have a real world meaning. b. they can be used in character strings like any other character value. c. they can be easily edited. d. they can be used in calculations like other numeric values. e. Dates and times are not stored as numeric values at all. d. - Answers -The following is the first few lines of an input file. Smith^Joe^27^1892^81059 Franks^Carl^24^2343^84060 Well^Sam^32^4569^ Max^Cori^21^1052^ Which statement should be used to read in the file referenced by the fileref persons? a. infile persons dlm; b. infile persons '^'; c. infile persons

d. Stat 124 Final Exam d - Answers -The data step has completed processing for five records, two of which had a data error. At the end of the fifth record, which of the following could be the correct program data vector? The last values read in without errors were AC103, John, and

a. N Error ID Name Salary 6 1.. 0 b. N Error ID Name Salary 6 2. c. N Error ID Name Salary 5 2 AC103 John 45330 d. N Error ID Name Salary 6 1. c - Answers -Which of the following correctly creates four variables which give the total quarterly sales for each quarter given that the dataset SALES contains twelve variables, month1 through month12? a. data Quarterly; set Sales; array quarter{4}; array month{4,3}; do i=1 to 4; quarter{i}=0; do j=1 to 4; quarter{i}+month{i,j}; output; end; end;run; b. data Quarterly; set Sales; array quarter{4}; array month{4,3}; do i=1 to 5; quarter{i}=0; do j=1 to 4; quarter{i}+month{i,j}; end; end;run; c. data Quarterly; set Sales; array quarter{4}; array month{4,3}; do i=1 to 4; quarter{i}=0; do j=1 to 3; quarter{i}+month{i,j}; end; end;run; d. data Quarterly; set Sales; array quarter{4}; array month{4,3}; do i=1 to dim(quarter); quarter{i}=0; do j=1 to dim(month); quarter{i}+month{i,j}; end; end;run; c - Answers -The following program is submitted data wally; if AmountDue=. then AmountDue=100; AdditionalFees=50; AmountDue=.; TotalDue=(AmountDue+AdditionalFees)+0; run; What is the value of TotalDue variable in the output data set?

a. 100 b. 0 c.. (missing value) d. 50 a - Answers -Which of the following pieces of code appends the observations from dataB to the end of the dataset dataA? a. data dataC; set dataA dataB; run; b. data dataC; set dataA dataB; by variable1; run; c. data dataC; set dataA; set dataB; run; d. data dataC; merge dataA dataB; by variable1; run; c - Answers -When the code below is run, what is the value of the variable TotalSales for the last observation? data Sales; input Month $ Jobcode $ Sales; retain Totalsales 200; Totalsales + Sales; datalines; Jan EJK459 250 Feb EJK459 200 Mar EJK459 250 ; a. 700 b. 200 c. 900 d. 1000 e. 450 a - Answers -What variables are in sandbox when it is run? data sandbox(drop=Name Age);

d. 0 e. 10 f. 1 a - Answers -The variable sales in the data set employees has a format of 8.3. The variable sales in the data set daily has a format of dollar6.2. The following program is submitted. Assume one of the values for name is 'John'. data merged; merge employees daily; by name; /format sales comma5.2;/ run; What is the format of the variable name in the merged data set? a. None of the these. b. 6. c. 8. d. comma5.2. e. dollar6. d - Answers -What usually happens when a syntax error is detected? a. SAS continues to process the step. b. SAS continues to process the step, and the SAS log displays messages about the error. c. SAS stops processing the step in which the error occurred, and the Output window displays messages about the error. d. SAS stops processing the step in which the error occurred, and the SAS log displays messages about the error. a - Answers -The YEARCUTOFF= system option is set to 1930. What are the range of dates it covers? a. 1930- b. 1930- c. 1829- d. 1931- c - Answers -What does the following code produce? Assume gender, weight, and height are all categorical variables. proc freq data=mydata; tables genderweightheight;run; a. Two tables, one for each gender, with height groups on one axis and weight groups on another. Frequency and percent are found in each cell of the table.

b. One interactive, three-dimensional table that allows you to click and discover the frequency, percent, row, column, and depth percents for each of the 3-D cells. c. Two tables, one for each gender, with height groups on one axis and weight groups on another. Frequency, percent, row percent, and column percent are found in each cell of the tables. d. A single table with gender, weight, and height variables along with variables for frequency, percent, cumulative frequencies, and cumulative percents. d - Answers -Which of the following procedures will correctly display the label for the variable Coupon that is already permanently stored in the dataset? a. proc print data=bonds label; label Coupon='MyLabel'; run; b. proc print data=bonds; run; c. proc print data=bonds; label Coupon='MyLabel'; run; d. proc print data=bonds label; run; c - Answers -What is the function of the FILENAME statement in SAS? a. It associates a library reference with an external directory. b. It associates a file reference with a relational database. c. It associates a file reference with an external file. d. It associates a library reference with a relational database. a - Answers -Which of the following statements changes the first three letters of the variable Jobcode to 'MAN' if the variable JobDescription contains a word with the substring 'manage' (regardless of case) in it? a. if index(upcase(JobDescription),'MANAGE')>0 then substr(Jobcode,1,3)='MAN'; b. if index(JobDescription,'MANAGE')>0 then substr(Jobcode,1,3)='MAN'; c. if find(upcase(JobDescription),'MANAGE','t')=0 then substr(Jobcode,1,3)='MAN'; d. if find(JobDescription,'MANAGE','i')>0 then substr(Jobcode,3,1)='MAN'; a - Answers -What is contained in the dataset Averages created by the following program? proc means data=mydata mean max median; var weight height armspan; class gender; output out=work.averages mean= AvgWeight AvgHeight AvgArmspan max= MaxWeight MaxHeight MaxArmspan