My SAS Tutorials

Tuesday 23 October 2012

SQL interview Questions II

1>
data one;
infile datalines;
input name $ salary;
bonus=sum(salary);
datalines;
ram 220
sita 221
radha 222
ravan 223
arjun 224
;
run;
proc sql;
select sum(salary) as avgnonus
from one;
quit; What will be the value of bonus and avgbonus variable.

a>
bonus  Avgbonus
220     1110
221
222
223
224

b>
bonus    Avgbonus
 1110       220   
                  221
                  222
                  223
                   224
c>
bonus   Avgbonus
 .                   .
d>
It will not create the bonus and avgbonus   variable


2>
Which order by clause orders a report by descending state and descending city?
a>order by state,city
b>order by desc state,  city
c>order by state desc, city desc
d>order by desc  state, desc  city

3>
Given the SAS data set ONE and TWO:
               One                                                        Two
   Year   QTR    Budget                        Year       QTR      Sales
   2001     3       500                             2001        4           300
   2001     4       400                             2001        2           200 
   2002     1       700                             2002        1           600
The following SAS program is submitted:
Proc sql ; 
    Select one.*, sales from one, two
           Where one.year=two.year;
 Quit;                                                                                                            
 Which report is generated?

a>
Year   Qtr  Budget   Sales
     2001  4      400         300
     2002  1      700         600
b>Year  Qtr   Budget   Sales
     2001  3       500        300
     2001  4       400        200
     2002  1       700        600
c>Year   Qtr    Budget  Sales
     2001   3        500       300
     2001   3        500       200
      2001   4        400       300
     2001   4        400       200
     2002   1        700       600
d>Year   Qtr     Budget  Sales
     2001   3        500        300
     2001   4        400        300
      2002  1    700  300
      2001  3     500  200
      2001  4     400  200
      2002  1    700   200
      2001  3    500   600
      2001  4    400   600
      2002  1   700    600

4>
Which syntax will select employee IDs having bonuses greater than $500?       
a>
select   employee_ID, salary*0.10 as bonus                                         
From test
Where  calculated bonus>500;
b>select employee_id, salary*0.10 as bonus                                                  
         from test having bonus>500;
c>both of the above
d>Neither of the above

5>
Proc SQL;
 Select   department , job_title , (find(job_title , "manager", "I")>0)  as manager
from test;                                                                                                                
 quit;                                                                                                                             
 what will be the observation of manager variable if it is able to find manager word in the joib_title variable?
a>10
b>1
c>0
d>5


6>Subqueries returns values to the outer queries:
a>Where and Having Clause
b>Order by Clause
c>From Clause
d>all

7>  Which statement is true?
   

a>     In noncorrelated subquery inner query is dependent on outer query
b>    in noncorrelated subquery inner query is not dependent on the outer query
c>     in correlated subquery inner query is not dependent on the outer query
d>     correlated and noncorrelated subquery returns values in the from clause.

     
   
   

8> Which statement is false?
a>A subquery is a query that resides within an outer query.
b>return values to be used in the outer query's WHERE and HAVING Clause
c>can return single or multiple values.
d>must return values from more than one column.

9>
Given the SAS data sets ONE and TWO:
              ONE                                                  TWO
    Num   Country                              Num    City
      1        Canada                                3         Paris
      2         France                                 5         Tokyo
      3         Germany
      4        Belgium
      5         Japan
   The following SAS program is submitted:
    Proc sql;
      Select country from one
          Where not exists
           (select * from two where one.num=two.num);
    Quit;

a>
Country
   France
    Japan
b>
   Country
     Germany
     Japan
c>
Country
     Canada
     France
     Belgium
d>
Country
     France
     Germany
     Belgium

10>
Which is false regarding the joins?
a>There are two types are   joins i.e inner joins and outer join .
b>Outer join is of three types: left , right and full join.
c>joins are used to combine two or more SAS data sets vertically.
d>We can combine only 2 tables in outer joins.

11>

Given the SAS dataset ONE
ONE
SALARY
----------
200
205
.
523

The following SAS program is submitted:
proc sql;
select *  from one
<insert WHERE expression here>;
quit;
The following output is desired:
SALARY
----------
200
205
523

a>where salary ne null
b>   where salary is not .
c> where salary ne missing
d>where salary is not missing

12>
Complete the SELECT clause below to create a new column named Profit by
subtracting the values of the column Cost from those of the column Price.
 select   fruit, cost, price,
a> Profit=price-cost
b> price-cost as Profit
c> profit=price-cost
d>Profit as price-cost

13>
What happens if you use a GROUP BY clause in a PROC SQL step without a
summary function?
   

a>     The step does not execute
b>    The first numeric column is summed by default
c>     The GROUP BY clause is changed to an ORDER BY clause.
d>    The step executes but does not group or sort data.

   
   
       

14>
If you specify a CREATE TABLE statement in your PROC SQL step,

a>the results of the query are displayed, and a new table is created.
b>a new table is created, but it does not contain any summarization that was
specified in the PROC SQL step.
c> a new table is created, but no report is displayed.
d> results are grouped by the value of the summarized column.


15>
          A Cartesian product is returned when



a>     join conditions are not specified in a PROC SQL join.
b>    join conditions are not specified in a PROC SQL set operation.
c>     more than two tables are specified in a PROC SQL join.
d>    the keyword ALL is used with the OUTER UNION operator.



Now prepare your Base SAS and Advance SAS Certification Exams with Online Mock tests:  http://exam.sankhyana.com




For training related info kindly mail us at info@sankhyana.com
www.sankhyana.com








                                                                                                                       










Sunday 21 October 2012

Base SAS interview Questions III






  1. The following SAS program is submitted:
    data test;
    set sasuser.employees;
    if 2 le years_service le 10 then
    amount = 1000;
    else if years_service gt 10 then
    amount = 2000;
    else
    amount = 0;
    amount_per_year = years_service / amount;
    run;
    Which one of the following values does the variable AMOUNT_PER_YEAR contain if an employee has been with the company for
    one year?
    A. 0
    B. 1000
    C. 2000
    D. . (missing numeric value)

  1. The contents of the raw data file AMOUNT are listed below:
    --------10-------20-------30
    $1,234
    The following SAS program is submitted:
    data test;
    infile 'amount';
    input @1 salary 6.;
    if _error_ then description = 'Problems';
    else description = 'No Problems';
    run;
    Which one of the following is the value of the DESCRIPTION variable?
    A. Problems
    B. No Problems
    C. ' ' (missing character value)
    D. The value can not be determined as the program fails to execute due to errors.

  1. The contents of the raw data file NAMENUM are listed below:
    --------10-------20-------30
    Joe xx
    The following SAS program is submitted:
    data test;
    infile 'namenum';
    input name $ number;
    run;
    Which one of the following is the value of the NUMBER variable?
    A. xx
    B. Joe
    C. . (missing numeric value)
    D. The value can not be determined as the program fails to execute due to errors.

  1. The contents of the raw data file AMOUNT are listed below:
    --------10-------20-------30
    $1,234
    The following SAS program is submitted:
    data test;
    infile 'amount';
    input @1 salary 6.;
    run;
    Which one of the following is the value of the SALARY variable?
    A. 1234
    B. 1,234
    C. $1,234
    D. . (missing numeric value)

  1. Which one of the following statements is true regarding the SAS automatic _ERROR_ variable?
    A. The _ERROR_ variable contains the values 'ON' or 'OFF'.
    B. The _ERROR_ variable contains the values 'TRUE' or 'FALSE'.
    C. The _ERROR_ variable is automatically stored in the resulting SAS data set.
    D. The _ERROR_ variable can be used in expressions or calculations in the DATA step.

  1. Which one of the following is true when SAS encounters a data error in a DATA step?
    A. The DATA step stops executing at the point of the error, and no SAS data set is created.
    B. A note is written to the SAS log explaining the error, and the DATA step continues to execute.
    C. A note appears in the SAS log that the incorrect data record was saved to a separate SAS file for further examination.
    D. The DATA step stops executing at the point of the error, and the resulting DATA set contains observations up to that point.

  1. The following SAS program is submitted:
    data work.totalsales (keep = monthsales{12} );
    set work.monthlysales (keep = year product sales);
    array monthsales {12} ;
    do i=1 to 12;
    monthsales{i} = sales;
    end;
    run;
    The data set named WORK.MONTHLYSALES has one observation per month for each of five years for a total of 60 observations.
    Which one of the following is the result of the above program?
    A. The program fails execution due to data errors.
    B. The program fails execution due to syntax errors.
    C. The program executes with warnings and creates the WORK.TOTALSALES data set.
    D. The program executes without errors or warnings and creates the WORK.TOTALSALES data set.

  1. The following SAS program is submitted:
    data work.totalsales;
    set work.monthlysales(keep = year product sales);
    retain monthsales {12} ;
    array monthsales {12} ;
    do i = 1 to 12;
    monthsales{i} = sales;
    end;
    cnt + 1;
    monthsales{cnt} = sales;
    run;
    The data set named WORK.MONTHLYSALES has one observation per month for each of five years for a total of 60 observations.
    Which one of the following is the result of the above program?
    A. The program fails execution due to data errors.
    B. The program fails execution due to syntax errors.
    C. The program runs with warnings and creates the WORK.TOTALSALES data set with 60 observations.
    D. The program runs without errors or warnings and creates the WORK.TOTALSALES data set with 60 observations.

  1. 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?
    A. PRODUCT and SALES only
    B. PRODUCT, MONTH, NUM_SOLD and COST only
    C. PRODUCT, SALES, MONTH, NUM_SOLD and COST only
    D. An incomplete output data set is created due to syntax errors.

  1. The contents of the raw data file CALENDAR are listed below:
    --------10-------20-------30
    01012000
    The following SAS program is submitted:
    data test;
    infile 'calendar';
    input @1 date mmddyy10.;
    if date = '01012000'd then event = 'January 1st';
    run;
    Which one of the following is the value of the EVENT variable?
    A. 01012000
    B. January 1st
    C. . (missing numeric value)
    D. The value can not be determined as the program fails to execute due to errors.

  1. A SAS program is submitted and the following SAS log is produced:
    2 data gt100;
    3 set ia.airplanes
    4 if mpg gt 100 then output;
    22 202
    ERROR: File WORK.IF.DATA does not exist.
    ERROR: File WORK.MPG.DATA does not exist.
    ERROR: File WORK.GT.DATA does not exist.
    ERROR: File WORK.THEN.DATA does not exist.
    ERROR: File WORK.OUTPUT.DATA does not exist.
    ERROR 22-322: Syntax error, expecting one of the following: a name,
    a quoted string, (, ;, END, KEY, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_.
    ERROR 202-322: The option or parameter is not recognized and will be ignored.
    5 run;
    The IA libref was previously assigned in this SAS session.
    Which one of the following corrects the errors in the LOG?
    A. Delete the word THEN on the IF statement.
    B. Add a semicolon at the end of the SET statement.
    C. Place quotes around the value on the IF statement.
    D. Add an END statement to conclude the IF statement.

  1. The contents of the raw data file SIZE are listed below:
    --------10-------20-------30
    72 95
    The following SAS program is submitted:
    data test;
    infile 'size';
    input @1 height 2. @4 weight 2;
    run;
    Which one of the following is the value of the variable WEIGHT in the output data set?
    A. 2
    B. 72
    C. 95
    D. . (missing numeric value)

  1. A SAS PRINT procedure output of the WORK.LEVELS data set is listed below:
    Obs name level
    1 Frank 1
    2 Joan 2
    3 Sui 2
    4 Jose 3
    5 Burt 4
    6 Kelly .
    7 Juan 1
    The following SAS program is submitted:
    data work.expertise;
    set work.levels;
    if level = . then
    expertise = 'Unknown';
    else if level = 1 then
    expertise = 'Low';
    else if level = 2 or 3 then
    expertise = 'Medium';
    else
    expertise = 'High';
    run;
    Which of the following values does the variable EXPERTISE contain?
    A. Low, Medium, and High only
    B. Low, Medium, and Unknown only
    C. Low, Medium, High, and Unknown only
    D. Low, Medium, High, Unknown, and ' ' (missing character value)

  1. The contents of the raw data file EMPLOYEE are listed below:
    --------10-------20-------30
    Ruth 39 11
    Jose 32 22
    Sue 30 33
    John 40 44
    The following SAS program is submitted:
    data test;
    infile 'employee';
    input employee_name $ 1-4;
    if employee_name = 'Ruth' then input idnum 10-11;
    else input age 7-8;
    run;
    Which one of the following values does the variable IDNUM contain when the name of the employee is "Ruth"?
    A. 11
    B. 22
    C. 32
    D. . (missing numeric value)

  1. The contents of the raw data file EMPLOYEE are listed below:
    --------10-------20-------30
    Ruth 39 11
    Jose 32 22
    Sue 30 33
    John 40 44
    The following SAS program is submitted:
    data test;
    infile 'employee';
    input employee_name $ 1-4;
    if employee_name = 'Sue' then input age 7-8;
    else input idnum 10-11;
    run;
    Which one of the following values does the variable AGE contain when the name of the employee is "Sue"?
    A. 30
    B. 33
    C. 40
    D. . (missing numeric value)

  1. The following SAS program is submitted:
    libname sasdata 'SAS-data-library';
    data test;
    set sasdata.chemists;
    if jobcode = 'Chem2'
    then description = 'Senior Chemist';
    else description = 'Unknown';
    run;
    A value for the variable JOBCODE is listed below:
    JOBCODE
    chem2
    Which one of the following values does the variable DESCRIPTION contain?
    A. Chem2
    B. Unknown
    C. Senior Chemist
    D. ' ' (missing character value)

  1. The following SAS program is submitted:
    libname sasdata 'SAS-data-library';
    data test;
    set sasdata.chemists;
    if jobcode = 'chem3'
    then description = 'Senior Chemist';
    else description = 'Unknown';
    run;
    A value for the variable JOBCODE is listed below:
    JOBCODE
    CHEM3
    Which one of the following values does the variable DESCRIPTION contain?
    A. chem3
    B. Unknown
    C. Senior Chemist
    D. ' ' (missing character value)

  1. Which one of the following ODS statement options terminates output being written to an HTML file?
    A. END
    B. QUIT
    C. STOP
    D. CLOSE

  1. The following SAS program is submitted:

    proc means data = sasuser.shoes;
    where product in ('Sandal' , 'Slipper' , 'Boot');
    run;
    Which one of the following ODS statements completes the program and sends the report to an HTML file?
    A. ods html = 'sales.html';
    B. ods file = 'sales.html';
    C. ods file html = 'sales.html';
    D. ods html file = 'sales.html';

  1. The following SAS program is submitted:
    proc format;
    value score 1 - 50 = 'Fail'
    51 - 100 = 'Pass';
    run;
    proc report data = work.courses nowd;
    column exam;
    define exam / display format = score.;
    run;
    The variable EXAM has a value of 50.5.
    How will the EXAM variable value be displayed in the REPORT procedure output?
    A. Fail
    B. Pass
    C. 50.5
    D. . (missing numeric value)

  1. The following SAS program is submitted:
    options pageno = 1;
    proc print data = sasuser.houses;
    run;
    proc means data = sasuser.shoes;
    run;
    The report created by the PRINT procedure step generates 5 pages of output.
    What is the page number on the first page of the report generated by the MEANS procedure step?
    A. 1
    B. 2
    C. 5
    D. 6

  1. Which one of the following SAS system options displays the time on a report?
    A. TIME
    B. DATE
    C. TODAY
    D. DATETIME
Ans: b
  1. Which one of the following SAS system options prevents the page number from appearing on a report?
    A. NONUM
    B. NOPAGE
    C. NONUMBER
    D. NOPAGENUM

  1. The following SAS program is submitted:
    footnote1 'Sales Report for Last Month';
    footnote2 'Selected Products Only';
    footnote3 'All Regions';
    footnote4 'All Figures in Thousands of Dollars';
    proc print data = sasuser.shoes;
    footnote2 'All Products';
    run;
    Which one of the following contains the footnote text that is displayed in the report?
    A. All Products
    B. Sales Report for Last Month
    All Products
    C. All Products
    All Regions
    All Figures in Thousands of Dollars
    D. Sales Report for Last Month
    All Products
    All Regions
    All Figures in Thousands of Dollars

  1. The following SAS program is submitted:
    proc means data = sasuser.houses std mean max;
    var sqfeet;
    run;
    Which one of the following is needed to display the standard deviation with only two decimal places?
    A. Add the option MAXDEC = 2 to the MEANS procedure statement.
    B. Add the statement MAXDEC = 7.2; in the MEANS procedure step.
    C. Add the statement FORMAT STD 7.2; in the MEANS procedure step.
    D. Add the option FORMAT = 7.2 option to the MEANS procedure statement.

  1. Unless specified, which variables and data values are used to calculate statistics in the MEANS procedure?
    A. non-missing numeric variable values only
    B. missing numeric variable values and non-missing numeric variable values only
    C. non-missing character variables and non-missing numeric variable values only
    D. missing character variables, non-missing character variables, missing numeric variable values, and non-missing numeric variable
    values

  1. The following SAS program is submitted:
    proc sort data = sasuser.houses out = houses;
    by style;
    run;
    proc print data = houses;

    run;
    Click on the Exhibit button to view the report produced.
    style bedrooms baths price
    CONDO 2 1.5 80050
    3 2.5 79350
    4 2.5 127150
    2 2.0 110700
    RANCH 2 1.0 64000
    3 3.0 86650
    3 1.0 89100
    1 1.0 34550
    SPLIT 1 1.0 65850
    4 3.0 94450
    3 1.5 73650
    TWOSTORY 4 3.0 107250
    2 1.0 55850
    2 1.0 69250
    4 2.5 102950
    Which of the following SAS statement(s) create(s) the report?
    A. id style;
    B. id style;
    var style bedrooms baths price;
    C. id style;
    by style;
    var bedrooms baths price;
    D. id style;
    by style;
    var style bedrooms baths price;

  1. A realtor has two customers. One customer wants to view a list of homes selling for less than $60,000. The other customer wants
    to view a list of homes selling for greater than $100,000.
    Assuming the PRICE variable is numeric, which one of the following PRINT procedure steps will select all desired observations?
    A. proc print data = sasuser.houses;
    where price lt 60000;
    where price gt 100000;
    run;
    B. proc print data = sasuser.houses;
    where price lt 60000 or price gt 100000;
    run;
    C. proc print data = sasuser.houses;
    where price lt 60000 and price gt 100000;
    run;
    D. proc print data = sasuser.houses;
    where price lt 60000 or where price gt 100000;
    run;

  1. The value 110700 is stored in a numeric variable.
    Which one of the following SAS formats is used to display the value as $110,700.00 in a report?
    A. comma8.2
    B. comma11.2
    C. dollar8.2
    D. dollar11.2

  1. The SAS data set SASUSER.HOUSES contains a variable PRICE which has been assigned a permanent label of "Asking Price".
    Which one of the following SAS programs 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 label = "Sale Price";
    run;

  1. The SAS data set BANKS is listed below:
    BANKS
    name rate
    FirstCapital 0.0718
    DirectBank 0.0721
    VirtualDirect 0.0728
    The following SAS program is submitted:
    data newbank;
    do year = 1 to 3;
    set banks;
    capital + 5000;
    end;
    run;
    Which one of the following represents how many observations and variables will exist in the SAS data set NEWBANK?
    A. 0 observations and 0 variables
    B. 1 observations and 4 variables
    C. 3 observations and 3 variables
    D. 9 observations and 2 variables

  1. The following SAS program is submitted:
    data work.clients;
    calls = 6;
    do while (calls le 6);
    calls + 1;
    end;
    run;
    Which one of the following is the value of the variable CALLS in the output data set?
    A. 4
    B. 5
    C. 6
    D. 7

  1. The following SAS program is submitted:
    data work.pieces;
    do while (n lt 6);
    n + 1;
    end;
    run;
    Which one of the following is the value of the variable N in the output data set?
    A. 4
    B. 5
    C. 6
    D. 7

  1. The following SAS program is submitted:
    data work.sales;
    do year = 1 to 5;
    do month = 1 to 12;
    x + 1;
    end;
    end;
    run;
    Which one of the following represents how many observations are written to the WORK.SALES data set?
    A. 0
    B. 1
    C. 5
    D. 60

  1. A raw data record is listed below:
    --------10-------20-------30
    1999/10/25
    The following SAS program is submitted:
    data projectduration;
    infile 'file-specification';
    input date $ 1 - 10;

    run;
    Which one of the following statements completes the program above and computes the duration of the project in days as of today's
    date?
    A. duration = today( ) - put(date,ddmmyy10.);
    B. duration = today( ) - put(date,yymmdd10.);
    C. duration = today( ) - input(date,ddmmyy10.);
    D. duration = today( ) - input(date,yymmdd10.);

  1. A raw data record is listed below:
    --------10-------20-------30
    Printing 750
    The following SAS program is submitted:
    data bonus;
    infile 'file-specification';
    input dept $ 1 - 11 number 13 - 15;

    run;
    Which one of the following SAS statements completes the program and results in a value of 'Printing750' for the DEPARTMENT
    variable?
    A. department = trim(dept) number;
    B. department = dept input(number,3.);
    C. department = trim(dept) || put(number,3.);
    D. department = input(dept,11.) || input(number,3.);

  1. 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?
    A. numeric, 8 bytes
    B. numeric, 10 bytes
    C. character, 8 bytes
    D. character, 10 bytes

  1. 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?
    A. 1001/5461
    B. 1001/ 5461
    C. . (missing numeric value)
    D. The value can not be determined as the program fails to execute due to errors.

  1. 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?
    A. 2000
    B. '2000'
    C. . (missing numeric value)
    D. ' ' (missing character value)

  1. Which one of the following SAS statements correctly computes the average of four numerical values?
    A. average = mean(num1 - num4);
    B. average = mean(of num1 - num4);
    C. average = mean(of num1 to num4);
    D. average = mean(num1 num2 num3 num4);

  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 data set?
    A. 1
    B. 6
    C. 15
    D. 200

  1. The following SAS program is submitted:
    data work.test;
    Author = 'Christie, Agatha';
    First = substr(scan(author,2,' ,'),1,1);
    run;
    Which one of the following is the value of the variable FIRST in the output data set?
    A. A
    B. C
    C. Agatha
    D
    . ' ' (missing character value)

  1. The following SAS program is submitted:
    data work.test;
    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?
    A. T
    B. of
    C. Dickens
    D. ' ' (missing character value)

  1. 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?
    A. 6
    B. 7
    C. 17
    D. 25

  1. 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?
    A. Ipswich!!
    B. Ipswich, England
    C. Ipswich, 'England'
    D. Ipswich , England

  1. Which one of the following is true of the RETAIN statement in a SAS DATA step program?
    A. It can be used to assign an initial value to _N_ .
    B. It is only valid in conjunction with a SUM function.
    C. It has no effect on variables read with the SET, MERGE and UPDATE statements.
    D. It adds the value of an expression to an accumulator variable and ignores missing values.
Ans: c or d
  1. A raw data file is listed below:
    --------10-------20-------30
    1901 2
    1905 1
    1910 6
    1925 .
    1941 1
    The following SAS program is submitted and references the raw data file above:
    data coins;
    infile 'file-specification';
    input year quantity;

    run;
    Which one of the following completes the program and produces a non-missing value for the variable TOTQUANTITY in the last
    observation of the output data set?
    A. totquantity + quantity;
    B. totquantity = sum(totquantity + quantity);
    C. totquantity 0;
    sum totquantity;
    D. retain totquantity 0;
    totquantity = totquantity + quantity;

  1. A raw data file is listed below:
    --------10-------20-------30
    squash 1.10
    apples 2.25
    juice 1.69
    The following SAS program is submitted using the raw data file above:
    data groceries;
    infile 'file-specification';
    input item $ cost;

    run;
    Which one of the following completes the program and produces a grand total for all COST values?
    A. grandtot = sum cost;
    B. grandtot = sum(grandtot,cost);
    C. retain grandtot 0;
    grandtot = sum(grandtot,cost);
    D. grandtot = sum(grandtot,cost);
    output grandtot;

  1. The following SAS program is submitted:
    data work.total;
    set work.salary(keep = department wagerate);
    by department;
    if first.department then payroll = 0;
    payroll + wagerate;
    if last.department;
    run;
    The SAS data set WORK.SALARY, currently ordered by DEPARTMENT, contains 100 observations for each of 5 departments.
    Which one of the following represents how many observations the WORK.TOTAL data set contains?
    A. 5
    B. 20
    C. 100
    D. 500

  1. The following SAS program is submitted:
    data work.total;
    set work.salary(keep = department wagerate);
    by department;
    if first.department then payroll = 0;
    payroll + wagerate;
    if last.department;
    run;
    The SAS data set named WORK.SALARY contains 10 observations for each department, currently ordered by DEPARTMENT.
    Which one of the following is true regarding the program above?
    A. The BY statement in the DATA step causes a syntax error.
    B. FIRST.DEPARTMENT and LAST.DEPARTMENT are variables in the WORK.TOTAL data set.
    C. The values of the variable PAYROLL represent the total for each department in the WORK.SALARY data set.
    D. The values of the variable PAYROLL represent a total for all values of WAGERATE in the WORK.SALARY data set.

  1. 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?
    A. 6 bytes
    B. 8 bytes
    C. 14 bytes
    D. 200 bytes

  1. 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

  1. The following SAS DATA step is submitted:
    data work.accounting;
    set work.department;
    length jobcode $ 12;
    run;
    The 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?
    A. 5
    B. 8
    C. 12
    D. The length can not be determined as the program fails to execute
    due to errors.

  1. Which one of the following SAS statements renames two variables?
    A. set work.dept1
    work.dept2(rename = (jcode = jobcode)
    (sal = salary));
    B. set work.dept1
    work.dept2(rename = (jcode = jobcode
    sal = salary));
    C. set work.dept1
    work.dept2(rename = jcode = jobcode
    sal = salary);
    D. set work.dept1
    work.dept2(rename = (jcode jobcode)
    (sal salary));
Ans: b
  1. 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?
    A. The variable JCODE is written to the output data set.
    B. The variable JOBCODE is written to the output data set.
    C. Neither variable JCODE nor JOBCODE is written to the output data set.
    D. The program fails to execute due to errors.

  1. The following SAS program is submitted:
    data work.passengers;
    if OrigPassengers = . then
    OrigPassengers = 100;
    TransPassengers = 100;
    OrigPassengers = .;
    NonPaying = 10;
    TotalPassengers = sum (OrigPassengers, TransPassengers);
    run;
    Which one of the following is the value of the TOTALPASSENGERS variable in the output data set?
    A. 100
    B. 110
    C. 200
    D. . (missing numeric value)

  1. 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?
    A. FA
    B. FA1
    C. FA 1
    D. ' ' (missing character value)

  1. 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?
    A. 6
    B. 9
    C. . (missing numeric value)
    D. The program fails to execute due to errors.

  1. The SAS data set named WORK.TEST is listed below:
    capacity airplanetype staff
    150 Large 10
    Which one of the following SAS programs created this data set?
    A. data work.test;
    capacity = 150;
    if 100 le capacity le 200 then
    airplanetype = 'Large' and staff = 10;
    else airplanetype = 'Small' and staff = 5;
    run;
    B. data work.test;
    capacity = 150;
    if 100 le capacity le 200 then
    do;
    airplanetype = 'Large';
    staff = 10;
    end;
    else
    do;
    airplanetype = 'Small';
    staff = 5;

    end;
    run;
    C. data work.test;
    capacity = 150;
    if 100 le capacity le 200 then
    do;
    airplanetype = 'Large';
    staff = 10;
    else
    do;
    airplanetype = 'Small';
    staff = 5;
    end;
    run;
    D. data work.test;
    capacity = 150;
    if 100 le capacity le 200 then;
    airplanetype = 'Small';
    staff = 5;
    else;
    airplanetype = 'Large';
    staff = 10;
    run;

  1. The following SAS program is submitted:
    data work.flights;
    destination = 'cph';
    select(destination);
    when('LHR') city = 'London';
    when('CPH') city = 'Copenhagen';
    otherwise city = 'Other';
    end;
    run;
    Which one of the following is the value of the CITY variable?
    A. Other
    B. Copenh
    C. Copenhagen
    D. ' ' (missing character value)

  1. The following SAS program is submitted:
    data work.flights;
    destination = 'CPH';
    select(destination);
    when('LHR') city = 'London';
    when('CPH') city = 'Copenhagen';
    otherwise;
    end;
    run;
    Which one of the following is the value of the CITY variable?
    A. London
    B. Copenh
    C. Copenhagen
    D. ' ' (missing character value)

  1. The following SAS program is submitted:
    data work.new;
    length word $7;
    amount = 4;
    if amount = 4 then word = 'FOUR';
    else if amount = 7 then word = 'SEVEN';
    else word = 'NONE!!!';
    amount = 7;
    run;
    Which one of the following represents the values of the AMOUNT and WORD variables?
    A. amount word
    7 FOUR
    B. amount word
    7 SEVEN
    C. amount word
    4 FOUR
    D. amount word
    4 ' ' (missing character value)

  1. The SAS data set EMPLOYEE_INFO is listed below:
    IDNumber Expenses
    2542 100.00
    3612 133.15
    2198 234.34
    2198 111.12
    The following SAS program is submitted:
    proc sort data = employee_info;

    run;
    Which one of the following BY statements completes the program and sorts the data sequentially by descending expense values within
    each descending IDNUMBER value?
    A. by descending IDNumber Expenses;
    B. by (IDNumber Expenses) descending;
    C. by IDNumber descending Expenses descending;
    D. by descending IDNumber descending Expenses;

  1. The SAS data set QTR1_REVENUE is listed below:
    destination revenue
    YYZ 53634
    FRA 62129
    FRA 75962
    RDU 76254
    YYZ 82174
    The following SAS program is submitted:
    proc sort data = qtr1_revenue;
    by destination descending revenue;
    run;
    Which one of the following represents the first observation in the output data set?
    A. destination revenue
    YYZ 82174
    B. destination revenue
    YYZ 53634
    C. destination revenue
    FRA 62129
    D. destination revenue
    FRA 75962

  1. The following SAS program is submitted:
    libname company 'SAS-data-library';
    proc sort data = company.payroll;
    by EmployeeIDNumber;
    run;
    Write access has been granted to the COMPANY library.
    Which one of the following represents how the observations are sorted?
    A. COMPANY.PAYROLL is recreated in sorted order by EmployeeIDNumber.
    B. COMPANY.PAYROLL is stored in original order, and a new data set PAYROLL is created in sorted order by
    EmployeeIDNumber.
    C. COMPANY.PAYROLL is stored in original order, and a new data set COMPANY.PAYROLLSORTED is created in sorted order
    by EmployeeIDNumber.
    D. COMPANY.PAYROLL is recreated in sorted order by EmployeeIDNumber, and a new data set PAYROLL is created in sorted
    order by EmployeeIDNumber.
Ans: a
  1. The SAS data set EMPLOYEE_INFO is listed below:
    IDNumber Expenses
    2542 100.00
    3612 133.15
    2198 234.34
    2198 111.12
    The following SAS program is submitted:
    proc sort data = employee_info;

    run;
    Which one of the following BY statements completes the program and sorts the data sequentially by ascending expense values within
    each ascending IDNUMBER value?
    A. by Expenses IDNumber;
    B. by IDNumber Expenses;
    C. by ascending (IDNumber Expenses);
    D. by ascending IDNumber ascending Expenses;

  1. The SAS data set WORK.AWARDS is listed below:
    fname points
    Amy 2
    Amy 1
    Gerard 3
    Wang 3
    Wang 1
    Wang 2
    The following SAS program is submitted:
    proc sort data = work.awards;
    by descending fname points;
    run;
    Which one of the following represents how the observations are sorted?
    A. Wang 3
    Gerard 3
    Wang 2
    Amy 2
    Wang 1
    Amy 1
    B. Wang 3
    Wang 2
    Wang 1
    Gerard 3
    Amy 2
    Amy 1
    C. Wang 3
    Wang 1
    Wang 2
    Gerard 3
    Amy 2
    Amy 1
    D. Wang 1
    Wang 2
    Wang 3
    Gerard 3
    Amy 1
    Amy 2

  1. The observations in the SAS data set WORK.TEST are ordered by the values of the variable NAME.
    The following SAS program is submitted:
    proc sort data = work.test out = work.testsorted;
    by name;
    run;
    Which one of the following is the result of the SAS program?
    A. The data set WORK.TEST is stored in ascending order by values of the NAME variable.
    B. The data set WORK.TEST is stored in descending order by values of the NAME variable.
    C. The data set WORK.TESTSORTED is stored in ascending order by values of the NAME variable.
    D. The data set WORK.TESTSORTED is stored in descending order by values of the NAME variable.

  1. Which one of the following statements is true regarding the name of a SAS array?
    A. It is saved with the data set.
    B. It can be used in procedures.
    C. It exists only for the duration of the DATA step.
    D. It can be the same as the name of a variable in the data set.



Now prepare your Base SAS and Advance SAS Certification Exams with Online Mock tests:  http://exam.sankhyana.com


For training related info kindly mail us at info@sankhyana.com
Sankhyana Consultancy Services
www.sankhyana.com