30 + Base SAS Certification Questions and Answers

The following is a list of Base SAS Certification Questions and Answers, that can help you to clear the Base SAS certification exam.

QUESTION 1:

The SAS data set SASUSER.HOUSES contains a variable PRICE which has been assigned a permanent label of “Asking Price”. Which SAS program temporarily replaces the label “Asking Price” with the label “Sale Price” in the output?

A. proc print data = sasuser.houses; label price = "Sale Price"; run;
B. proc print data = sasuser.houses label; label price "Sale Price"; run;
C. proc print data = sasuser.houses label; label price = "Sale Price"; run;
D. proc print data = sasuser.houses; price = "Sale Price"; run;

Correct Answer: C

Explanation:

When a label statement is placed in a data step, the label stays with the variable for all subsequent procedures, unless relabeled. When placed in a procedure the label only stays attached to the variable for that procedure.

The correct syntax for assigning labels in Proc steps is

PROC procedure-name DATA= dataset-name LABEL;LABEL variable-name='Label';RUN;

QUESTION 2

The following SAS program is submitted:

data work.empsalary;
set work.people (in = inemp)
work.money (in = insal);
if insal and inemp;
run;

The SAS data set WORKPEOPLE has 5 observations, and the data set WORK.MONEY has 7 observations. How many observations will the data set WORK.EMPSALARY contain?

  1. 0
  2. 5
  3. 7
  4. 12

Correct Answer: A

Explanation:

SAS reads WORK.PEOPLE dataset first and then WORK.MONEY. The IN option is applied in both the datasets. The IF statement is used to determine whether both the dataset contributed to the current observation. This is false because the first dataset(WORK.PEOPLE) is read first and then the second(WORK.EMPSALARY). So there are no matches.

Reference: Set Statment in SAS.

QUESTION 3:

The following SAS program is submitted:

data work.accounting;
set work.dept1 work.dept2;
jobcode = 'FA1';
length jobcode $ 8;
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. What is the length of the variable JOBCODE in the output data set?

  1. 3
  2. 5
  3. 7
  4. 8

Correct Answer: B

Explanation:

The length of the variable is 5 because the first dataset has a length of 5 and SAS reads the first dataset first. The length statement has no effect because it is used after the set statement where the length has already been loaded.

QUESTION 4:

The following SAS program is submitted:

data one;
addressl = '214 London Way'; 
run;
data one; 
set one; 
address = tranwrd(address1,Way', Drive'); 
run;

What are the length and value of the variable ADDRESS?

  1. Length is 14; value is ‘214 London Dri’.
  2. Length is 14; value is ‘214 London Way’.
  3. Length is 16; value is ‘214 London Drive’.
  4. Length is 200; value is ‘214 London Drive’.

Correct Answer: D

Explanation:

The value returned from a TRANWRD function has a default length of 200. The first argument of the TRANWRD function is replaced with the second argument.

Reference: The Ultimate Guide To SAS Character Functions

QUESTION 5:

The following SAS program is submitted:

data combine;
 prefix='505';
 middle='6465';
 end='09090';
 ;
<insert statement here>
run;

Which statement successfully completes the program so that TOTAL has a value of 505-6465- 09090?

A. total = cat('-', prefix, middle, end)
B. total = catx('-', prefix, middle, end)
C. total = prefix !!'-'!! middle ``!!'-'!! end
D. total = prefix!!'-'!! left(middle)!!'-'!! end

Correct Answer: B

Explanation:

The CATX function removes leading and trailing blanks inserts delimiters provided in the first argument and returns a concatenated character string.

Reference: The Ultimate Guide To SAS Character Functions

QUESTION 6:

The following SAS program is submitted;

data combine;
country = 'Italy, Russia, ireland'; 
found = find(country,'i');
run;

What is the value of the variable FOUND in the output data set?

  1. 1
  2. 12
  3. Italy
  4. Russia

Correct Answer: B

Explanation:

The second argument to the find function is the substring that is used to find in the main string (first argument). Any modifiers, like ‘i'(to ignore case), is to be specified in the third argument.

Reference: The Ultimate Guide To SAS Character Functions

QUESTION 7:

The following SAS program is submitted:

data WORK.ONE;
 Text='Australia, US, Denmark';
 Pos=find(Text,'US','i',5);
run;

What value will SAS assign to Pos?

  1. 0
  2. 1
  3. 2
  4. 12

Correct Answer: D

Explanation:

The last argument(5)to the find function, tell SAS to start finding for the character from 5th position, However, the result will be calculated from the first position. Hence, the result is 12.

Reference: The Ultimate Guide To SAS Character Functions

QUESTION 8:

The SAS data set WORK.ONE contains a numeric variable named Numeric and character variable named Character:

WORK.ONE

30 + Base SAS Certification Questions and Answers

The following SAS program is submitted:

proc print data=WORK.ONE;
 where Numeric='1';
run;

What is the output?

  1. Numeric Character
    • 1 23
  2. Numeric Character
    • 1 23
    • 1 77
  3. Numeric Character
    • 1 23
    • 3 23
    • 1 77
  4. No output is generated.

Correct Answer: D

Explanation:

There is no output because the where statement is checking for character date(within quotes) in a numeric variable. The below Error message also written to the SAS log.

ERROR: WHERE clause operator requires compatible variables.

QUESTION 9:

The following SAS program is submitted:

data work.sets;
 do until (prod gt 6);
 prod + 1;
 end;
run;

What is the value of the variable PROD in the output data set?

  1. 6
  2. 7
  3. 8
  4. . (missing numeric)

Correct Answer: B

Explanation:

The expression prod gt 6 is evaluated at the bottom of the loop. There are five iterations in all (1, 2, 3, 4, 5, 6). Since prod+1 assignment statement is used, implicit retain is applied and the value of prod is retained to 0.

  • 1st loop Prod = 1 gt 6 False Value of prod is 0+1=1
  • 2nd loop Prod = 2 gt 6 False value of prod 0+1 = 2
  • 5th loop Prod = 5 gt 6 False value of prod 0+5 = 5
  • 6th loop Prod = 6 gt 6 False value of prod 0+6 = 6
  • 7th loop Prod = 7 gt 6 True, the loop exits and PDV writes Prod value to 7

Reference: SAS Loops Explained

QUESTION 10:

Which statement correctly computes the average of four numerical values?

A. average = mean(num1, num4)
B. average = mean(num1 - num4)
C. average = mean(of num1 - num4)
D. average = mean(num1 num2 num3 num4)

Correct Answer: C

Reference: SAS Numeric functions and Operators

QUESTION 11:

The following SAS code is submitted:

data work.total;
 infile 'file' end='eof';
 input Month $ Price;
 tot_price+price;
run;
A. if end = 0;&nbsp
B. if eof = 0
C. if end = 0
D. if end = 1

Correct Answer: D

The END= option creates a numeric (0 or 1) temporary variable that indicates that the last record has been read. For the last record, the temporary variable would have a value of 1.

Reference: Exploring the SET Statement in SAS

QUESTION 12:

Given is a SAS dataset WORK.INPUT.

30 + Base SAS Certification Questions and Answers

The following SAS program is submitted:

data WORK.ONE WORK.TWO;
     set WORK.INPUT;
     if var1 = 'A' then output WORK.ONE;
     OUTPUT;
 run;

The number of observations in the WORK.ONE dataset will be __________

Answer: 8

Explanation: The two statements (if var1=’A’) and (output) are independent. For every observation in work. input, it will be outputted to both the dataset because of the output statement. So, in work. one dataset there are 8 observations. (5+3=8)

QUESTION 13:

The following SAS program is submitted:

data WORK.TEMP;
 char1='0123456789';
 char2=substr(char1,3,4);
run;

What is the value of char2?

  1. 23
  2. 34
  3. 345
  4. 2345

Correct Answer: D

Reference: The Ultimate Guide To SAS Character Functions

QUESTION 14:

The following SAS program is submitted:

data work.TITLES;
 Title = 'A Tale of Two Cities, Charles J. Dickens';
 Word = scan(title,3,',');
 run;

Which one of the following is the value of the variable WORD in the output data set?

  1. T
  2. of
  3. Dickens
  4. ‘ ‘ (Missing Character Values)

Correct Answer: D

Reference: The Ultimate Guide To SAS Character Functions

QUESTION 15:

Given the following code:

proc print data=SASHELP.CLASS(firstobs=5 obs=15);
 where Sex='M';
run;

How many observations will be displayed?

  1. 11
  2. 15
  3. 10 or fewer
  4. 11 or fewer

Correct Answer: D

Only the first 15 observations are available to be printed (OBS=15); However, the first to be printed is the 4th observation (FIRSTOBS=5).

Reference: Data set Options in SAS

QUESTION 16:

The following SAS program is submitted:

data ONE TWO SASUSER.TWO
 set SASUSER.ONE;
run;

Assuming that SASUSER.ONE exists, how many temporary and permanent SAS data sets are created?

  1. 2 temporary and 1 permanent SAS data sets are created.
  2. 3 temporary and 2 permanent SAS data sets are created.
  3. 2 temporary and 2 permanent SAS data sets are created.
  4. there is an error and no new data sets are created.

Correct Answer: D

QUESTION 17:

The following SAS program is submitted:

data WORK.ACCOUNTING;
 set WORK.DEPARTMENT;
 label Jobcode='Job Description';
run;

Which statement is true about the output dataset?

  1. The label of the variable Jobcode is Job (only the first word).
  2. The label of the variable Jobcode is Job Desc (only the first 8 characters).
  3. The label of the variable Jobcode is Job Description.
  4. The program fails to execute due to errors. Labels must be defined in a PROC step.

Correct Answer: C

Reference: LABEL Statement

QUESTION 18:

data WORK.NEW;
 set WORK.OLD;
 Count+1;
 run;

The variable Count is created using a sum statement. Which statement regarding this variable is true?

  1. It is assigned a value 0 when the data step begins execution.
  2. It is assigned a value of missing when the data step begins execution.
  3. It is assigned a value 0 at compile time.
  4. It is assigned a value of missing at compile time.

Correct Answer: C

The variable count will get the default initial value of 0 just before the data step read the first observation.

QUESTION 19:

The following SAS program is submitted:

 data work.month;
  date = put('13mar2000'd,ddmmyy10.);
 run;

Which one of the following represents the type and length of the variable DATE in the output data set?

  1. numeric, 8 bytes
  2. numeric, 10 bytes
  3. character, 8 bytes
  4. character, 10 bytes

Correct Answer: D

Explanation: The put function converts numeric to character thus the date be displayed as 03/13/2000, taking up 10 bytes.

Reference: Variable conversions in SAS

QUESTION 20:

The following SAS program is submitted:

data work.month;
 date = input('13mar2000',date9.);
run;

Which one of the following represents the type and length of the variable DATE in the output data set?

  1. numeric, 8 bytes
  2. numeric, 9 bytes
  3. character, 8 bytes
  4. character, 9 bytes

Correct Answer: A

Explanation: The input function converts a character to numeric and numeric variables are always stored in 8 bytes.

QUESTION 21:

The following SAS program is submitted:

data work.products;
 Product_Number = 5461;
 Item = '1001';
 Item_Reference = Item'/'Product_Number;
 run;

Which one of the following is the value of the variable ITEM_REFERENCE in the output data set?

  1. 1001/5461
  2. 1001/ 5461
  3. . (missing numeric value)
  4. The value can not be determined as the program fails to execute due to errors.

Correct Answer: D

QUESTION 22:

The following SAS program is submitted:

data work.retail;
 cost = '20000';
 total = .10 * cost;
 run;

Which one of the following is the value of the variable TOTAL in the output data set?

  1. 2000
  2. ‘2000’
  3. . (missing numeric value)
  4. ‘ ‘ (missing character value)

Correct Answer: A

Explanation: SAS will convert the variable cost to numeric automatically. 20000*0.1=2000

QUESTION 23:

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 data set?

  1. 1
  2. 6
  3. 15
  4. 200

Correct Answer: C

Explanation: In a DATA step, if the SCAN function returns a value to a variable that has not yet been given a length, that variable is given the length of the first argument. (In this case, it is 15). The default length for the substr function is the longest character it can extract from a character variable of length n that is 15.

QUESTION 24:

The following SAS program is submitted:

data work.test;
 First = 'Ipswich, England';
 City_Country = substr(First,1,7)!!', '!!'England';
 run;

Which one of the following is the length of the variable CITY_COUNTRY in the output data set?

  1. 6
  2. 7
  3. 17
  4. 25

Correct Answer: D

Explanation: The variable-length returned in substr function is determined by the length of the first argument. So, 16(Ipswich, England) + 2(‘, ‘) + 7(‘England’) = 25

QUESTION 25:

The following SAS program is submitted:

data work.test;
 First = 'Ipswich, England';
 City = substr(First,1,7);
 City_Country = City!!', '!!'England';
 run;

Which one of the following is the value of the variable CITY_COUNTRY in the output data set?

  1. Ipswich!!
  2. Ipswich, England
  3. Ipswich, ‘England’
  4. Ipswic h, England

Correct Answer: B

QUESTION 26:

The following SAS program is submitted:

libname sasdata 'SAS-data-library';
 data test;
 set sasdata.chemists (keep = job_code);
 if job_code = 'chem3'
 then description = 'Senior Chemist';
 run;

The variable JOB_CODE is a character variable with a length of 6 bytes.
Which one of the following is the length of the variable DESCRIPTION in the output data set?

  1. 6 bytes
  2. 8 bytes
  3. 14 bytes
  4. 200 bytes

Correct Answer: C

QUESTION 27:

The following SAS DATA step is submitted:

data work.accounting;
set work.department;
 length jobcode $ 12;
 run;

WORK. DEPARTMENT SAS data set contains a character variable named JOBCODE with a length of 5. Which one of the following is the length of the variable JOBCODE in the output data set?

  1. 5
  2. 8
  3. 12
  4. The length can not be determined as the program fails to execute due to errors.

Correct Answer: A

QUESTION 28:

The following SAS program is submitted:

data work.company;
 set work.dept1(keep = jobcode)
 work.dept2(rename = (jcode = jobcode));
 run;

Which one of the following is the result?

  1. The variable JCODE is written to the output data set.
  2. The variable JOBCODE is written to the output data set.
  3. Neither variable JCODE nor JOBCODE is written to the output data set.
  4. The program fails to execute due to errors.

Correct Answer: B

QUESTION 29:

The following SAS program is submitted:

data work.staff;
 JobCategory = 'FA';
 JobLevel = '1';
 JobCategory = JobCategory || JobLevel;
 run;

Which one of the following is the value of the variable JOBCATEGORY in the output data set?

  1. FA
  2. FA1
  3. FA 1
  4. ‘ ‘ (missing character value)

Correct Answer: A

QUESTION 30:

The following SAS program is submitted:

data work.one;
 x = 3;
 y = 2;
 z = x ** y;
 run;

Which one of the following is the value of the variable Z in the output data set?

  1. 6
  2. 9
  3. . (missing numeric value)
  4. The program fails to execute due to errors.

Correct Answer: B

Explanation: ** is for exponentiation, X**Y raise X to the power of Y, So 3 at the power of 2 = 9

QUESTION 31:

The following SAS program is submitted:

data allobs;
 set sasdata.origin (firstobs = 75 obs = 499);
 run;

The SAS data set SASDATA.ORIGIN contains 1000 observations.

How many observations do the ALLOBS data set contain?

  1. 424
  2. 425
  3. 499
  4. 1000

Correct Answer: B

QUESTION 32:

The following SAS program is submitted:

data work.january;
 set work.allmonths (keep = product month num_sold cost);
if month = 'Jan' then output work.january;
 sales = cost * num_sold;
 keep = product sales;
 run;

Which variables does the WORK.JANUARY data set contain?

  1. PRODUCT and SALES only
  2. PRODUCT, MONTH, NUM_SOLD and COST only
  3. PRODUCT, SALES, MONTH, NUM_SOLD and COST only
  4. An incomplete output data set is created due to syntax errors.

Correct Answer: D

Every week we'll send you SAS tips and in-depth tutorials

JOIN OUR COMMUNITY OF SAS Programmers!

Subhro

Subhro provides valuable and informative content on SAS, offering a comprehensive understanding of SAS concepts. We have been creating SAS tutorials since 2019, and 9to5sas has become one of the leading free SAS resources available on the internet.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.