Advanced SAS 9 ExamPrep SritejGunta

download Advanced SAS 9 ExamPrep SritejGunta

of 60

Transcript of Advanced SAS 9 ExamPrep SritejGunta

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    1/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej Gunta1. The following SAS program is submitted:

    DATA TEMP;LENGTH A 1 B 3 X;

    INFILE ‘FILE-REFERENCE’; 

    INPUT A B X;RUN;

    What is the result?

    A. The data set TEMP is created and variable X has a length of 8

    B. The data set TEMP is not created because variable A has an invalid lengthC. The data set TEMP is not created because variables A and B have invalid lengthsD. The data set TEMP is created, but variable X is not created

    2. The data set SASUSER.HIGHWAY is given below:

    STEERING SEATBELT SPEED STATUS COUNT-------- -------- ----- ------- -----

    Absent No 0-29 Serious 31Absent No 0-29 Not 1419

    Absent No 30-49 Serious 191Absent No 30-49 Not 2004Absent No 50+ Serious 216

    The following SAS program is submitted:

    %MACRO HIGHWAY;

    PROC SQL NOPRINT;SELECT COUNT(DISTINCT STATUS)

    INTO :NUMGRPFROM SASUSER.HIGHWAY;

    %LET NUMGRP=&NUMGRP;SELECT DISTINCT STATUS

    INTO :GROUP1-:GROUP&NUMGRPFROM SASUSER.HIGHWAY;

    QUIT;%DO i=1 %TO &NUMGRP;PROC PRINT DATA=SASUSER.HIGHWAY;

    WHERE STATUS=’&&GROUP&i’; 

    RUN;%END;%MEND;%HIGHWAY

    How many reports are produced by the above program?

    A. 1B. 0

    C. 2D. 5

    3. The data set ONE is given below:

    NUM VAR--- ---

    1 A2 B3 C

    Which one of the following SQL programs deletes the SAS data set ONE?

    A. PROC SQL;

    DELETE TABLE ONE;

    QUIT;

    B. PROC SQL;

    ALTER TABLE ONE DROP NUM, VAR;

    QUIT;

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    2/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej Gunta

    C. PROC SQL;

    DROP TABLE ONE;QUIT;

    D. PROC SQL;DELETE FROM ONE;

    QUIT;

    4. The data set ONE is given below:

    CATEGORY AGE SALARY BONUS

    -------- --- ------ -----M 28 200 20

    M 25 100 10M 28 300 10

    M 33 300 30F 18 100 50

    F 25 200 10F 35 400 50

    The following SAS program is submitted:

    PROC SQL;

    CREATE TABLE TWO ASSELECT DISTINCT AGEFROM ONE

    WHERE AGE < 33;QUIT;

    How many rows are written to the SAS data set TWO?

    A. 3B. 5

    C. 6D. 4

    5. The following SAS program is submitted:

    DATA SASUSER.HISTORY;SET SASUSER.HISTORY (KEEP=STATE X Y RENAME=(STATE=ST));

    TOTAL=SUM(X,Y);RUN;

    The SAS data set SASUSER.HISTORY has an index on the variable STATE.

    Which describes the result of submitting the SAS program?

    A. The index on STATE is updated as an index on STB. The index on STATE is deleted and an index on ST is created

    C. The index on STATE is recreated as an index on STD. The index on STATE is deleted

    6. The SAS data set ONE contains fifty million observations and contains the variables PRICE, QUANTITY, FIXED, andVARIABLE.

    Which SAS program successfully creates three new variables TOTREV, TOTCOST, and PROFIT and requires the least amountof CPU resources to be processed?

    A. DATA TWO;SET ONE;

    TOTREV=SUM(PRICE*QUANTITY);

    TOTCOST=SUM(FIXED,VARIABLE);IF TOTREV > 1000;

    PROFIT=SUM(TOTREV,-TOTCOST);

    RUN;

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    3/60

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    4/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej Gunta

    B. REP AREA TOTAL

    JONES EAST 100JONES NORTH 600JONES WEST 500

    SMITH NORTH 800SMITH SOUTH 200

    C. REP AREA TOTALJONES EAST 100

    JONES NORTH 600JONES WEST 500

    SMITH NORTH 800SMITH SOUTH 200

    D. REP AREA TOAL

    JONES EAST 1JONES NORTH 2JONES WEST 3

    SMITH NORTH 3SMITH SOUTH 1

    9. Which statement(s) in the DATASETS procedure alter(s) the name of a SAS data set stored in a SAS data library?

    A. RENAME statement onlyB. CHANGE statement onlyC. MODIFY and RENAME statementsD. MODIFY and CHANGE statements

    10. The following SAS program is submitted:

    %LET VALUE=9;%LET ADD=5;%LET NEWVAL=%EVAL(&VALUE/&ADD);

    Which is the value of the macro variable NEWVAL?

    A. 1.8

    B. 2C. 1D. Null

    1. (B) The LENGTH statement does not determine the width of the display value (that is controlled by FORMAT) but ratherthe number of bytes used for storing variable values. Because the SAS default is to assign numeric type to inputvariables (and this example lacks the necessary $ preceding the number for character type), these variables are

    clearly assigned a numeric type.

    This program fails initially because numeric values must be assigned a length of between 2 to 8 (typically 3 to 8)

    depending on the operating environment. So, variable A has been assigned an improper length.

    An additional error would occur on variable X. It is assigned in the LENGTH statement, but it is not given a variablelength.

    2. (C) This SAS program is composed of a macro program called HIGHWAY which spans from the %MACRO statement to the %MENDstatement.

    When the macro program is called, it executes the code within that span. The NOPRINT option in the PROC SQL statementindicates that no report will be generated; that is, no table is printed in the output window.

    The INTO clause creates macro variables equal to the number of distinct values in the STATUS column. Therefore, thereare two values (1 and 2) for the two distinct statuses (SERIOUS and NOT).

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    5/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej GuntaThe PRINT procedure generates a number of reports based on a %DO loop which gets its span from the number of distinctSTATUS values. So, 1 %TO 2. Therefore, two reports are generated from two PRINT procedures.

    3. (C) A ‘table’ in SQL language is synonymous with ‘data set’ in SAS. So, to delete an entire data set using PROC SQL,you must invoke the DROP TABLE statement using the following syntax:

    DROP TABLE table-name-1 ;

    Where table-name specifies the name of the table(s) to be dropped.

    4. (A) The first thing PROC SQL does is execute the FROM clause. This eliminates the observations where the variable AGE

    possesses a value greater than or equal to 33. So, this leaves five observations.

    The next thing it does is create a new table called TWO while only using the variable AGE from data set ONE. Withinthis, it uses the keyword DISTINCT to select only unique values for the variable AGE. This eliminates the duplicatesand leaves only three observations.

    5. (D) An index  is an optional file that can be created for a SAS data file in order to provide direct access tospecific observations.

    SAS maintains indexes for all changes to the table, whether the changes originate from PROC SQL or some other source,

    as long as the entire table is not re-created. If you alter a column’s definition or update its values, then SAS willupdate the indexes also. However, if a key column in a table is dropped (deleted), then the index on that column isalso dropped.

    As you can see, the SET statement identifies the same data set as the DATA statement. Therefore, the data set is re-created and all indexes are deleted.

    6. (C) First, understand that SAS evaluates code line by line sequentially. Without knowing anything else besides that,

    you can eliminate option (B) because it is attempting to apply a WHERE clause with an expression to a variable thatdoesn’t even exist in the data set. Therefore, SAS will clearly return an error and the program will fail.

    The next thing to understand is a fundamental difference between WHERE statements and the subsetting IF statement.

    Normally, when you’re attempting to subset data, the WHERE statement is more efficient because it can evaluate data

    in the buffer before it decides whether or not to pass it along to the program data vector (PDV). On the other hand,

    the subsetting IF statement must wait until the data has entered the PDV before it can be evaluated based onprescribed conditions.

    The catch in this instance is that a WHERE statement can only select observations from SAS data sets, whereas the IFstatement can select records from external files, observations from SAS data sets, observations created with an INPUT

    statement, or, in this case, observations based on the value of a computed or derived variable.

    Because TOTREV is a created variable, the WHERE statement is unable to subset it in the same DATA step, and theprogram fails.

    This leaves you with only options (A) and (C) to consider. Both would accomplish the task, but option (A) does notattempt to subset until after it’s already created an additional variable (TOTCOST). Therefore, it’s more efficientto evaluate the subsetting IF and decide whether or not to pass on the record immediately after TOTREV has beencreated instead of creating an additional variable that may just be discarded anyway.

    7. (D) The ARRAY statement has the following syntax:

    ARRAY array-name {subscript} ;

    In this example, the array name is SCORE. The subscript describes the number and arrangement of elements in thearray. In this instance, the asterisk is used which specifies that SAS is to determine the subscript by counting thevariables in the array rather than you specifically identifying it.

    The array-elements specify the names of the elements that make up the array. If they happen to possess aconsecutively named format, a hyphen can be used for a short-hand listing method.

    So, A4-A10 creates seven separate elements and A25 is the additional eighth.

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    6/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej Gunta8. (D) The first thing SAS does is evaluate the FROM clause. It grabs the table (or data set) called ONE, and then using

    the SELECT clause it extracts the variables REP and AREA from that table.

    It then creates a variable called TOTAL by implementing the COUNT summary function which basically just counts the

    number of rows. Once they’ve been grouped, you can see there is one row that possesses the attributes JONES and EAST,two rows that have JONES and NORTH, and three rows of JONES and WEST.

    Note: The COST variable was left out from the GROUP BY clause. If it had been included, all of the values for TOTAL

    would have been 1 except for JONES and WEST. There’d be two listings for JONES and WEST because of the differing COSTvariable.

    9. (B) You can use the DATASETS procedure to alter the name of an established data set using the CHANGE statement. Thesyntax is as follows:

    PROC DATASETS LIBRARY=libref  ;CHANGE old-data-set-name = new-data-set-name;

    QUIT;

    Note: The RENAME statement allows you to rename variables as a file management task using the DATASETS procedure.This method does not require DATA step processing.

    The MODIFY statement changes the attributes of a SAS file and, through the use of subordinate statements, theattributes of variables in the SAS file.

    10. (C) The %LET statement allows you to create your own macro variable and assign a value to it. In this example, themacro variable VALUE is created with a value of 9, and the macro variable  ADD is created with a value of 5.

    The %EVAL function evaluates integer arithmetic or logical expressions. However, if an operation results in a non-integer value, %EVAL truncates the value to an integer.

    Using standard arithmetic, we know that 9 divided by 5 equals 1.8. As was previously mentioned, SAS truncates non-integer values. It does not round them. So, the 1.8 is truncated to an integer value of 1.

    11. Which one of the following SORT procedure options eliminates identical, consecutive observations?

    A. DISTINCTB. NODUPKEY

    C. NODUPD. UNIQUE

    12. The following SAS program is submitted:

    DATA NEW (BUFSIZE=6144 BUFNO=4);

    SET OLD;RUN;

    What is the difference between the usage of BUFSIZE= and BUFNO= options?

    A. BUFSIZE= specifies the size of the output buffer in kilobytes; BUFNO= specifies the number of output buffers

    B. BUFSIZE= specifies the size of the input buffer in bytes; BUFNO= specifies the number of input buffersC. BUFSIZE= specifies the size of the input buffer in kilobytes; BUFNO= specifies the number of input buffersD. BUFSIZE= specifies the size of the output buffer in bytes; BUFNO= specifies the number of output buffers

    13. The following SAS code is submitted:

    %macro houses(dsn=houses, sub=RANCH);DATA &dsn;

    SET sasuser.houses;IF style=’&sub’; 

    RUN;%mend;%houses(sub=SPLIT)

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    7/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej Gunta%houses(dsn=ranch)%houses(sub=TWOSTORY)

    Which of the following is the value of the automatic macro variable SYSLAST?

    A. WORK.HOUSESB. work.houses

    C. WORK.RANCHD. work.ranch

    14. The data set SASHELP.CLASS is given below:

    NAME AGE------ ---

    Mary 15Philip 16Robert 12

    Ronald 15

    The following SAS program is submitted:

    %LET VALUE=Philip;PROC PRINT DATA=SASHELP.CLASS;

    < insert WHERE statement here >RUN;

    Which WHERE statement successfully completes the program and produces a report?

    A. WHERE UPCASE(NAME)=UPCASE(&VALUE);B. WHERE UPCASE(NAME)=”UPCASE(&VALUE)”; 

    C. WHERE UPCASE(NAME)=”%UPCASE(&VALUE)”;D. WHERE UPCASE(NAME)=%UPCASE(&VALUE);

    15. The non-indexed SAS data set TEMP is given below:

    X Y- --

    P 52P 45

    A 13A 56

    R 34R 12R 78

    The following SAS program is submitted:

    PROC PRINT DATA=TEMP;

    < insert BY statement here >RUN;

    Which BY statement completes the program, creates a listing report that is grouped by X, and completes withouterrors?

    A. BY X;

    B. BY DESCENDING X;C. BY X GROUPED;D. BY X NOTSORTED;

    16. The following SAS program is submitted:

    %LET A=cat;%MACRO ANIMAL(A=frog);

    %LET A=bird;%MEND;

    %ANIMAL(A=pig)%PUT A is &A;

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    8/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej GuntaWhich one of the following is written to the SAS log?

    A. A is birdB. A is cat

    C. A is &AD. A is pig

    17. The following SAS program is submitted:

    %MACRO CHECK(NUM=4);%LET RESULT=%EVAL(&NUM GT 5);%PUT Result is &RESULT;%MEND;%CHECK(NUM=10)

    What is written to the SAS log?

    A. Result is 10 GT 5B. Result is TRUE

    C. Result is 1D. Result is 0

    18. The following SAS program is submitted:

    %MACRO CHECK(NUM=4);%LET RESULT=%SYSEVALF(&NUM+0.5);

    %PUT Result is &RESULT;%MEND;%CHECK(NUM=10)

    What is written to the SAS log?

    A. Result is 10+0.5

    B. Result is

    C. Result is 10D. Result is 10.5

    19. Which one of the following is an advantage of creating and using a SAS DATA step view?

    A. It works quickly through multiple passes of the dataB. It always accesses the most current dataC. It can store an index

    D. It is useful when the underlying data file structure changes

    20. The following SAS program is submitted:

    DATA TEMP;ARRAY POINTS{2,3} (10,15,20,25,30,35);

    RUN;

    What impact does the ARRAY statement have in the Program Data Vector (PDV)?

    A. The variables named POINTS10, POINTS15, POINTS20, POINTS25, POINTS30, and POINTS35 are created in the PDVB. The variables named POINTS1, POINTS2, POINTS3, POINTS4, POINTS5, and POINTS6 are created in the PDVC. The variables named POINTS11, POINTS12, POINTS13, POINTS21, POINTS22, and POINTS23 are created in the PDVD. No variables are created in the PDV

    11. (C) The NODUP option causes PROC SORT to compare all variable values for an observation to the previous one writtento the output data set. Therefore, when using the NODUP option, the data set must be sorted by enough variables to

    ensure that the observations are in the correct order to remove all duplicates.

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    9/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej GuntaNote: The NODUPKEY option checks for and eliminates observations with duplicate BY values. If you specify this

    option, then PROC SORT compares all BY values for each observation to the ones for the previous observation that is

    written to the output data set. If an exact match is found, then the observation is not written to the output dataset.

    12. (D) 

    13. (A) SYSLAST is an automatic SAS variable that names the most recently created SAS data set, in the form LIBREF.NAME.This value is always stored in all capital letters. If no data set has been created, the value is _NULL_.

    In this example, the %MACRO statement assigns two keyword parameters (dsn and sub) with the two values (houses andRANCH, respectively). These macro variables are the defaults for the macro program houses.

    The first time the macro houses is called, it executes with the macro variable dsn having the value houses, and themacro variable sub has its default value replaced with SPLIT . Hence, the most recently executed data set isWORK.HOUSES.

    The macro houses is called a second time. This time the dsn macro variable has a substituted value of ranch, and themacro variable sub has a value of RANCH . Hence, the most recently executed data set is WORK.RANCH.

    The macro houses is called a third time. In this instance, the macro variable dsn has a value of houses, and themacro variable sub has a value of TWOSTORY . Hence, the most recently executed data set, and the answer, is

    WORK.HOUSES.

    Note: You may view automatic SAS variables values by evoking the SYMBOLGEN system option. For example: OPTIONSSYMBOLGEN;

    14. (C) The UPCASE function copies a character argument, converts all lowercase letters to uppercase letters, and returnsthe altered value as a result.

    When you’re attempting to apply the UPCASE function to a macro variable, you must precede the enclosed macro variablein parentheses with the %UPCASE function.

    15. (D) Option (A) returns an error because in the data set TEMP, it was not already sorted by the variable X inascending order. Option (B) returns an error as well because the data set TEMP was not previously sorted in ascending

    order. Option (C) returns an error because GROUPED is not an option. SAS assumes it’s a variable that it can’t find. 

    The NOTSORTED option allows you to group observations in a data set by the formatted values of the BY variableswithout requiring that the data be sorted or indexed.

    16. (B) In this example, you have the creation of a global macro variable A with a value of cat created at the beginning.There’s also a macro program called ANIMAL with a keyword parameter attached.

    When the macro ANIMAL is called, it has a new keyword parameter assigned: variable A with the value pig. However,when this parameter is applied to the macro, the value of variable A is immediately overwritten with bird .

    Therefore, you have a local macro variable A which resolves to bird  within the macro program, and a global macrovariable A that resolves to cat outside the macro program.

    17. (C) The macro program CHECK creates a local macro variable NUM  with a value of 4. The macro call %CHECK(NUM=10)resolves the variable NUM  with a value of 10 when initialized.

    The %EVAL function evaluates integer arithmetic or logical expressions. In this instance, as a result of the %Letstatement in the macro program CHECK, it is being asked to perform a logical expression to check if the value of &NUM(which is 10) is greater than 5. If the result of the logical expression is true, SAS returns a value of 1. If it isfalse, SAS returns a value of 0. Quite clearly, 10 is greater than 5, so SAS returns a value of 1.

    Note: If the macro call %CHECK(NUM=10) had omitted the additional element (i.e. simply %CHECK), then SAS would have

    evaluated 4 against 5 and returned a value of 0.

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    10/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej Gunta18. (D) The macro program CHECK creates a local macro variable NUM  with a value of 4. The macro call %CHECK(NUM=10)

    resolves the variable NUM  with a value of 10 when initialized.

    The %SYSEVALF function is the only macro function that can evaluate arithmetic or logical expressions using floatingpoint or missing values. As you can see from the expression &NUM+0.5, floating point is necessary.

    When the macro call %CHECK(NUM=10) is initialized, it resolves the macro variable NUM  to 10. So, the expression isevaluated as 10+.05. Therefore, the variable RESULT  resolves to 10.5.

    19. (B) 

    20. (B) The ARRAY statement syntax is as follows:

    ARRAY array-name {subscript} ;

    In this example, the array-name is POINTS, but there are no array-elements explicitly named. When this is the case,SAS sequentially names each variable with the array-name. POINTS1 … POINTSn.

    21. The following SAS program is submitted:

    DATA NEW (BUFNO=4);SET OLD (BUFNO=4);

    RUN;

    Why are the BUFNO options used?

    A. To reduce memory usageB. To reduce the amount of data read

    C. To reduce network trafficD. To reduce the number of I/O operations

    22. The following SAS program is submitted:

    %MACRO TEST(VAR);%LET JOBS=BLACKSMITH WORDSMITH SWORDSMITH;

    %LET TYPE=%INDEX(&JOBS,&VAR);%MEND;%TEST(SMITH)

    Which one of the following is the resulting value of the macro variable TYPE?

    A. Null

    B. 0C. 6D. 3

    23. At the start of a new SAS session, the following program is submitted:

    %MACRO ONE;DATA _NULL_;

    CALL SYMPUT(‘PROC’,’MEANS’); 

    RUN;

    PROC &PROC DATA=SASHELP.CLASS;RUN;

    %MEND;%ONE()

    What is the result?

    A. The program fails to execute because PROC is a reserved keywordB. The macro variable PROC is stored in the local symbol table

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    11/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej GuntaC. The macro variable PROC is stored in the global symbol tableD. The macro variable PROC is stored in the SAS catalog WORK.SASMCR

    24. Which one of the following displays the definition of a stored SQL procedure view in the SAS log?

    A. ECHOVIEW option

    B. EXPANDVIEW optionC. DESCRIBE VIEW statementD. VALIDATE VIEW statement

    25. Which SAS procedure changes the name of a permanent format for a variable stored in a SAS data set?

    A. FORMAT

    B. DATASETSC. REGISTRYD. MODIFY

    26. The SAS data set ONE contains the variables X, Y, Z, and W, and it is sorted in ascending order by the X variable.

    The following SAS program is submitted:

    PROC TRANSPOSE DATA=ONEOUT=TRANSNAME=NEW;

    BY X;VAR Y;

    RUN;

    What are the names of all of the columns created by the TRANSPOSE procedure?

    A. NEW, X, Y, and _COL1_

    B. NEW, X, and Y onlyC. NEW, Y, and COL1 onlyD. NEW, X, and COL1 only

    27. Which one of the following SAS integrity constraint types ensures that a specific set or range of values are the onlyvalues in a variable?

    A. CHECK

    B. DISTINCT

    C. UNIQUED. FORMAT

    28. The following SAS program is submitted:

    DATA NEW;

    DO i=1,2,3;NEXTFILE=COMPRESS(“MARCH” || i || “.dat”);

    INFILE ABC FILEVAR=NEXTFILE END=EOF;

    END;DO UNTIL (EOF);INPUT DEPT $ SALES;

    END;RUN;

    What is the purpose of the FILEVAR= option on the INFILE statement?

    A. It names the variable NEXTFILE, whose values point to an aggregate storage locationB. It names the variable NEXTFILE, whose change in value causes an INFILE statement to open a new input fileC. It names the variable NEXTFILE, whose value is output to the SAS data set NEWD. It names the variable NEXTFILE, whose value is a SAS file reference

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    12/60

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    13/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej Gunta21. (D) The BUFNO= system or data set option controls the number of buffers that are available for reading or writing a

    SAS data set. By increasing the number of buffers, you can control how many pages of data are loaded into memory witheach I/O transfer.

    22. (C) The %INDEX function enables you to determine the position of the first character of a string within anotherstring. The syntax for the %INDEX function is as follows:

    %INDEX(source,string)

    Both source and string are character strings or text expressions that can include constant text, macro variablereferences, macro functions, or macro calls.

    In this example, the macro variable JOBS acts as the source and resolves to BLACKSMITH WORDSMITH SWORDSMITH . Themacro variable VAR acts as the string and resolves to SMITH  once the macro call %TEST(SMITH) is initialized.

    So, what SAS does is begin scanning from left to right within the source variable (BLACKSMITH WORDSMITH SWORDSMITH )until it finds the identified string variable (SMITH ). At that point it marks its location where the string variablefirst appears (6).

    Note: You can print this identifying location to the SAS log if you include the following statement within the macroprogram:

    %PUT &VAR is at position &TYPE.;

    Also, if you change the element in the macro call from SMITH  to SWORD, your new value will be 22.

    23. (C) When you use the DATA _NULL_ statement, SAS processes the DATA step without writing observations to a data set.Using the DATA _NULL_ statement can considerably increase program efficiency.

    The SYMPUT routine assigns DATA step information to a macro variable. The syntax is as follows:

    CALL SYMPUT(argument-1,argument-2);

    argument-1 specifies a character expression that identifies the macro variable that is assigned a value. If the macrovariable does not exist, the routine creates it.

    argument-2 specifies a character constant, variable, or expression that contains the value that is assigned.

    In this instance, the macro variable PROC  is created, and it is assigned a value of MEANS.

    So, when the macro ONE is called via %ONE(), the macro variable PROC resolves to MEANS and executes the MEANSprocedure.

    The macro ONE is created without any additional parameters (neither KEYWORD nor POSITIONAL parameters). When the

    macro ONE is called via %ONE(), the parentheses indicate that the default parameters for the macro are to be used.However, because none were used, it is moot. This method is synonymous with simply using %ONE;

    Typically, macro variables that are created within a macro are stored in the local symbol table and exist only during

    the execution of that macro that defines the variable. However, in this instance the macro variable is being used toexecute an active report (the MEANS procedure), and is therefore passed to the global symbol table.

    Note: You can verify this after running the PROC SQL code by viewing the DICTIONARY.MACROS table.

    PROC SQL;

    SELECT *FROM DICTIONARY.MACROS;

    QUIT;

    24. (C) The DESCRIBE VIEW statement displays a definition of a view in the SAS log.

    25. (B) The DATASETS procedure, when used in conjunction with the FORMAT statement, permanently assigns, changes, andremoves variable formats in the SAS data set specified in the MODIFY statement. The syntax is as follows:

    FORMAT variable-1 ;

    Where variable-1  specifies one or more variables whose format you want to assign, change or remove. Ifyou want to disassociate a format with a variable, list the variable last in the list with no format following.

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    14/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej Gunta

    26. (D) The PROC TRANSPOSE statement creates an output data set by restructuring values in a SAS data set, transposingselected variables into observations. The syntax is as follows:

    PROC TRANSPOSE 

    ;BY  variable-1 ... variable-n 

    ;

    VAR variable(s);RUN;

    If an output-data-set does not exist, PROC TRANSPOSE creates it by using the DATA n naming convention. Also, if youomit the VAR statement, the TRANSPOSE procedure transposes all of the numeric variables in the input data set that

    are not listed in another statement. And finally, you must list all character variables in a VAR statement if youwant to transpose them.

    So, in this example, we are transposing the data set ONE. The NAME= option specifies the name of the variable in the

    output data set that contains the name of the variable that is being transposed to create the current observation (ifit were omitted, the default name would be _NAME_). The VAR statement names one or more variables to transpose.

    With the NAME= option and VAR statement combined, you get a column named NEW with all the values in that column beingY.

    Because the output data set is being sorted with a BY statement, all the variables included with that BY statementwill also be in the output data set. Therefore, X is also a column name.

    Finally, the remaining variables listed are those of the listed variables. Here, the only transposed variable is Yand because the PREFIX= option was not used, the default column name is COL1.

    27. (A) The integrity constraint CHECK ensures that a specific set or range of values are the only values in a column. Itcan also check the validity of a value in one column based on a value in another column within a row.

    28. (B) The FILEVAR= option enables you to dynamically change the currently opened input file to a new input file.

    INFILE  file-specification FILEVAR=variable;

    Where FILEVAR=variable names a variable whose change in value causes the INFILE statement to close the current inputfile and open a new input file, and variable contains a character string that is a physical filename.

    When you use an INFILE statement with the FILEVAR= option, the file specification is a placeholder, not an actualfilename or a fileref that had been assigned previously to a file. SAS uses this placeholder for reporting processing

    information to the SAS log. The file specification must conform to the same rules as a fileref.

    29. (C) If you define a local macro variable and a global macro variable with the same name, the macro facility uses the

    value of the local variable during the execution of the macro that contains that local variable. When the macro thatcontains the local variable is not executing, the macro facility uses the value of the global variable.

    In this example, you can clearly see that the %LET statement creates a global macro variable called DATE with a valueof 31DEC2006.

    The CALL SYMPUT function in macro TWO also creates global a macro variable called DATE but with a value of 12SEP2008.However, this only occurs if the macro program TWO is called.

    As you can see, the macro program ONE is called with a macro variable parameter &DATE that resolves to 31DEC2006.

    So, when the macro program ONE executes, the initial value of the global macro variable DATE is 31DEC2006. However,the first line of code within the ONE macro program calls the macro program TWO which then executes within the ONE 

    macro program and the CALL SYMPUT function creates a global macro variable called DATE with a value of 12SEP2008 which overwrites the previous DATE macro variable value. This new value is then displayed in the PUT statement.

    Note: If the macro program TWO hadn’t been called (that is, removing %TWO; from macro program ONE), the %PUTstatement would have displayed: THE VALUE IS 31DEC2006.

    Additionally, if the %PUT statement had been placed before the call of macro program TWO (%TWO;), then the %PUTstatement would have printed 31DEC2006 before the macro variable DATE had its value overwritten.

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    15/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej Gunta

    30. (D) The first thing to notice is the SELECT clause. It extracts the variable LEVEL and creates the variable MAX.Hence, you can immediately eliminate options (A) and (B).

    A HAVING clause further refines a PROC SQL query by working with the GROUP BY clause to restrict the groups that aredisplayed to the output, based on one or more specific conditions.

    In this example, the HAVING clause specifies only groups which have a maximum AGE value greater than the average AGEof the entire table are to be displayed. The average AGE for the entire table is 17. The maximum values for groups 1,

    2, and 3 are 10, 30, and 30 (respectively). Therefore, group 1 does not qualify and only groups 2 and 3 are displayed

    in the output.

    31. When reading a SAS data file, what does the NOBS= option on the SET statement represent?

    A. A variable that represents the current observation number

    B. A variable that represents a flag indicating the end of the fileC. A variable that represents the total number of observations in the input data set(s)D. A variable that represents the total number of observations in the output data set(s)

    32. The following SAS program is submitted:

    %LET VALUE=0;%LET VALUE2=9;

    %LET NEWVAL=%EVAL(&VALUE/&VALUE2);

    Which one of the following is the resulting value of the macro variable NEWVAL?

    A. 9

    B. 2C. NullD. 0

    33. Which one of the following is the purpose of the IDXNAME= data set option?

    A. It instructs SAS to use any available index for WHERE processingB. It instructs SAS to use a specific index for WHERE processing

    C. It instructs SAS to name and store a specific indexD. It instructs SAS to store an index in a particular location

    34. The following SAS program is submitted:

    PROC CONTENTS DATA=TESTDATA.ONE;RUN;

    Which one of the following SQL statements produces similar information about the column attributes as the above

    CONTENTS procedure?

    A. PROC SQL;

    SHOW TABLE TESTDATA.ONE;QUIT;

    B. PROC SQL;

    SHOW TESTDATA.ONE;QUIT;

    C. PROC SQL;

    DESCRIBE TABLE TESTDATA.ONE;QUIT;

    D. PROC SQL;

    DESCRIBE TESTDATA.ONE;QUIT;

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    16/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej Gunta

    35. The following SAS program is submitted:

    %LET LIB=%UPCASE(sasuser);PROC SQL;

    SELECT NVAR

    FROM DICTIONARY.TABLES

    WHERE LIBNAME=”&LIB”;QUIT;

    Given that several SAS data sets exist in the SASUSER library, which one of the following is generated as output?

    A. A syntax error in the logB. A report showing the number of columns in each table in SASUSERC. No result set

    D. A report showing the names of each table in SASUSER

    36. Which one of the following SAS programs uses the most amount of memory resources for output buffers?

    A. DATA NEW (BUFSIZE=2000 BUFNO=3);

    SET TEMP;RUN;

    B. DATA NEW (BUFSIZE=4000 BUFNO=1);

    SET TEMP;RUN;

    C. DATA NEW (BUFSIZE=1000 BUFNO=5);SET TEMP;

    RUN;

    D. DATA NEW (BUFSIZE=1000 BUFNO=2);SET TEMP;

    RUN;

    37. The SAS data sets CLASS1 and CLASS2 are given below:

    CLASS1 CLASS2

    NAME COURSE NAME COURSE------ ------ ------ ------

    Lauren MATH1 Smith MATH2Patel MATH1 Farmer MATH2

    Chang MATH1 Patel MATH2Chang MATH3 Hiller MATH2

    The following SAS program is submitted:

    PROC SQL;

    SELECT NAMEFROM CLASS1

    < insert SQL set operator here >

    SELECT NAMEFROM CLASS2;

    QUIT;

    The following output is desired:

    NAME

    ------Chang

    ChangLauren

    Which SQL set operator completes the program and generates the desired output?

    A. EXCEPT ALL

    B. INTERSECT ALL

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    17/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej GuntaC. UNION ALLD. OUTER UNION ALL

    38. Which one of the following statements is true regarding a SAS DATA step view?

    A. It contains a partially compiled DATA step

    B. It allows write capabilitiesC. It contains global statementsD. It contains data and a descriptor portion

    39. The SAS data set WORK.TEMPDATA contains the variables FMTNAME, START, and LABEL and it consists of 10 observations.

    The following SAS program is submitted:

    PROC FORMAT CNTLIN=WORK.TEMPDATA;

    RUN;

    What is the result of submitting the FORMAT procedure?

    A. An ERROR message is written to the SAS log because the program is incomplete

    B. No formats are created in this stepC. All formats created will be stored in the WORK.TEMPDATA SAS data setD. It uses the WORK.TEMPDATA SAS data set as input to create the format

    40. The SAS data sets ONE and TWO are given below:

    ONE TWONUM COUNTRY NUM CITY

    --- ------- --- -------

    1 CANADA 3 BERLIN2 FRANCE 5 TOKYO

    3 GERMANY4 BELGIUM5 JAPAN

    The following SAS program is submitted:

    PROC SQL;SELECT COUNTRY

    FROM ONEWHERE NOT EXISTS

    (SELECT *

    FROM TWO

    WHERE ONE.NUM=TWO.NUM);QUIT;

    Which of the following reports is generated?

    A. COUNTRYCANADA

    FRANCE

    BELGIUM

    B. COUNTRYFRANCEBELGIUM

    C. COUNTRYGERMANYJAPAN

    D. COUNTRYCANADAFRANCEGERMANY

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    18/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej Gunta

    31. (C) The NOBS= option creates and names a temporary variable whose value is usually the total number of observationsin the input data set or data sets. If more than one data set is listed in the SET statement, NOBS= the total number

    of observations in the data sets that are listed. The number of observations includes those observations that aremarked for deletion but are not yet deleted.

    32. (D) A numerator is allowed to take on the value of zero in a fraction. Any legal fraction (denominator not equal tozero) with a numerator equal to zero has an overall value of zero.

    Note: Null is synonymous with missing. If the zero had instead been in the denominator, the answer would have insteadbeen Null and an error would have been written to the log.

    ERROR: Division by zero in %EVAL is invalid.

    33. (B) The IDXNAME= data set option directs SAS to use a specific index to match the conditions of a WHERE expression.

    Note: DO not confuse with the IDXWHERE= option which specifies whether or not SAS should use an index to process the

    WHERE expression, no matter which access method SAS estimates is faster.

    34. (C) The DESCRIBE TABLE statement lists all indexes for one or more tables that you specify, along with other

    information about the table(s).

    35. (B) The macro variable LIB is assigned the value sasuser. The %UPCASE function capitalizes all letters of the value,which is essential because that’s how it is stored within SAS, and encloses it in quotation marks. So, the libraryname has been specified.

    The variable of note is NVAR, which specifies the number of columns (or variables) for each table in the SASUSERlibrary.

    36. (A) The BUFNO= option specifies the number of buffers to be used. The BUFSIZE= option controls the page size of anoutput data set. To calculate which option requires the most amount of memory resources, simply multiply the valuefor BUFNO by the value for BUFSIZE.

    37. (A) The set operator EXCEPT does both of the following: (1) It selects unique rows from the first table (the table

    specified in the first query) that are not found in the second table (the table specified in the second query). (2)It overlays columns.

    The keyword ALL follows the operator and tells SAS to make only one pass through the data and does not removeduplicate rows.

    Note: If the data set CLASS2 contained a NAME variable with the value CHANG , the output table would have CHANG andLAUREN  because one CHANG  value in CLASS2 would cancel one of the two CHANG  values in CLASS1.

    38. (A) A DATA step view contains a partially compiled DATA step program that can read data from a variety of sources. ADATA step view can be created only in a DATA step. A DATA step view cannot contain global statements, host-specific

    data set options, or most host-specific FILE and INFILE statements. Also, a DATA step view cannot be indexed orcompressed.

    39. (D) You can create a format from a SAS data set that contains value information (called a control data set). To do

    this, you use the CNTLIN= option to read the data and create the format. The syntax is as follows:

    PROC FORMAT LIBRARY=libref.catalog CNTLIN=SAS-data-set;

    Where libref.catalog is the name of the catalog in which you want to store the format and SAS-data-set is the name ofthe SAS data set that you want to use to create the format.

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    19/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej GuntaThe data set that is used to create a format with the CNTLIN= option must have the variables FmtName, Start, andLabel. If a range is specified, it must also include the variable End.

    40. (A) The first thing you should notice is that the SELECT clause will only display one variable (or column), COUNTRY .

    The second is that the program involves a subquery. A subquery, or inner query, is a query-expression that is nested

    as part of another query-expression. In this instance, the subquery is used in conjunction with the WHERE NOT EXISTSexpression.

    This expression calls for all observations to be output where the value of the variables NUM in data sets ONE and TWOare not equal to each other. So, CANADA, FRANCE, and BELGIUM .

    41. Given the following SAS program:

    PROC SQL;

    SELECT PRODUCT, TYPE, SUM(SALES) AS REVENUEFROM ONE

    GROUP BY PRODUCT, TYPE;QUIT;

    Which one of the following clauses should be added to the program to sort the output by PRODUCT and decreasing

    REVENUE?

    A. ORDER BY 1, 3 DESC

    B. ORDERBY PRODUCT, REVENUE DESC

    C. ORDER BY 1, 3D. ORDER BY PRODUCT, DESC REVENUE

    42. The SAS data set ONE is given below:

    REP COST----- ----SMITH 200

    SMITH 400

    JONES 100

    SMITH 600JONES 100

    JONES 200

    JONES 400SMITH 800JONES 100JONES 300

    The following SAS program is submitted:

    PROC SQL;SELECT REP, AVG(COST) AS AVERAGE

    FROM ONEGROUP BY REP

    HAVING AVG(COST) > (SELECT AVG(COST) FROM ONE);

    QUIT;

    Which one of the following reports is generated?

    A. REP AVERAGE

    SMITH 320

    B. REP AVERAGEJONES 320

    C. REP AVERAGESMITH 500

    D. REP AVERAGEJONES 200

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    20/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej Gunta

    43. The following SAS program is submitted:

    %MACRO TEST(VAR);PROC PRINT DATA=SASUSER.CLASS;

    WHERE AGE > &VAR;

    RUN;%MEND;

    Which type of parameter is the macro variable VAR?

    A. PositionalB. CommandC. KeywordD. Default

    44. The following SAS program is submitted:

    %LET VAR=CHICAGO, 1;

    DATA A;

    VAR=’NEW YORK, 2’; NEWVAR=%SCAN(&VAR,2,%STR());

    RUN;

    Which one of the following explains why the program fails to execute?

    A. The %SCAN function has too many arguments

    B. The macro variable VAR does not get created properlyC. The %STR() is invalid syntaxD. The %SCAN function does not exist

    45. Which one of the following options displays the value of a macro variable in the SAS log?

    A. SOURCE

    B. MACROC. SYMBOLGEND. SOURCE2

    46. The DICTIONARY.MACROS table stores information about which of the following?

    A. User-defined macro variables only

    B. Macros stored in the autocall macro library onlyC. Both user- and system-defined macro variablesD. System-defined macro variables

    47. Which one of the following is true regarding the KEEP statement?

    A. The KEEP statement selects the variables read from the input data set(s)B. The KEEP statement applies only to the first data set created within the same DATA step if more than one data set

    is created

    C. The KEEP statement is available in both the DATA and PROC stepsD. The KEEP statement applies to all data sets created within the same DATA step

    48. Which one of the following is the purpose of the REUSE=YES option in a compressed SAS data set?

    A. It allows new observations to be inserted wherever enough free space existsB. It specifies that a new empty data set with a given name replaces an existing data set with the same nameC. It allows users to update the same SAS data set concurrentlyD. It temporarily compresses observations in a SAS data set

    49. The SAS data set ONE is given below:

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    21/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej GuntaGROUP SUM

    ----- ---

    A 765B 123C 564

    The following SAS program is submitted:

    DATA _NULL_;SET ONE;CALL SYMPUT(GROUP,SUM);

    RUN;

    Which one of the following is the result when the program finishes execution?

    A. Macro variable GROUP has a value of 564

    B. Macro variable C has a value of 1452C. Macro variable GROUP has a value of 1452D. Macro variable C has a value of 564

    50. The following SAS program is submitted:

    FILENAME SALES (‘EXTERNAL-FILE1’ ‘EXTERNAL-FILE2’); DATA NEW;

    INFILE SALES;

    INPUT DATE DATE9. COMPANY $ REVENUE;RUN;

    Which one of the following is the result of including the FILENAME statement in this program?

    A. The FILENAME statement associates SALES with EXTERNAL-FILE2 followed by EXTERNAL-FILE1B. The FILENAME statement associates SALES with EXTERNAL-FILE1 followed by EXTERNAL-FILE2

    C. The FILENAME statement reads record 1 from EXTERNAL-FILE1, reads record 1 from EXTERNAL-FILE2, and combines theminto one recordD. The FILENAME statement produces and ERROR message in the SAS log

    41. (A) The output table will contain three columns: PRODUCT , TYPE, and the created REVENUE column. When referencing

    these columns, they can also be identified by their position in the SELECT clause. So, PRODUCT =1, TYPE=2, andREVENUE=3.

    To sort the output data by PRODUCT and decreasing REVENUE, you can order by 1 to indicate PRODUCT and 3 to indicateREVENUE. To list REVENUE by decreasing values, place the keyword DESC after the column name.

    Note: The DESC  keyword in SQL performs the same task as the DESCENDING  keyword in the BY statement of a SORTprocedure. However, in the SORT procedure, the DESCENDING keyword comes before the variable you intend to reorder.

    Additionally, option (B) would have also been correct had the ORDER BY clause been written properly.

    42. (C) Note that the two columns in the output table will be REP and the created column AVERAGE.

    The GROUP BY clause places REP into the number of unique groups associated with the REP column (SMITH  and JONES).

    A HAVING clause further refines a PROC SQL query by working with the GROUP BY clause to restrict the groups that aredisplayed to the output, based on one or more specific conditions.

    In this example, the HAVING clause compares the average value of the COST  column of the entire data set ONE (which is320) against a subquery of the average COST of each group (SMITH and JONES) which are 500 and 200, respectively. Itwill then only output the groups which have an average cost greater than the average cost of the entire table. TheJONES group does not meet this requirement. Therefore, SMITH  is the only group that is output.

    43. (A) Parameters in a macro take the following syntax:

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    22/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej Gunta%MACRO  macro-name( parameter-1);

    text %MEND ;

    A positional macro parameter variable is one that can quite simply be referenced by its position in the parameter

    list. In this example, we have the macro statement %MACRO TEST(VAR);. The macro variable VAR is in the first positionbecause it is the only listed variable. We could easily list multiple macro variables. For example,  %MACROTEST(VAR,TYPE,WEIGHT); where the macro variable VAR is position 1, TYPE is position 2, and WEIGHT  is position 3.

    Note: This differs from keyword parameters because the order in which positional parameters are listed is important,and there are no assigned keywords. For example, %MACRO TEST(X1=VAR,X2=TYPE,X3=WEIGHT); is an example of keyword

    parameter macro variables where X1-X3 are the keywords that can be referenced in a macro which assigns theirrespected values.

    44. (A) This is a rather tricky question. The syntax for the %SCAN function is as follows:

    %SCAN (argument, n)

    Where argument consists of constant text, macro variable references, macro functions, or macro calls, and n is an

    integer or a text expression that yields an integer, which specifies the position of the word to return. If n isgreater than the number of words in argument, the function returns a null string. Lastly, the delimiters specify anoptional list of one or more characters that separate “words” or test expressions that yield one or more characters.  

    As you can see, the %LET statement creates a macro variable VAR with the entire value CHICAGO, 1.

    This macro variable is called upon in the data step. Once it’s inserted into the %SCAN function, the %SCAN functionreads too many arguments because it is read as %SCAN(CHICAGO, 1,2,%STR()).

    45. (C) When you submit a macro variable reference, the macro processor resolves the reference and passes the valuedirectly back to the input stack. You can use the SYMBOLGEN system option to monitor the value that is substitutedfor a macro variable reference.

    46. (C) DICTIONARY tables are special, read-only PROC SQL tables or views. They retrieve information about all the SASlibraries, SAS data sets, SAS system options, and external files that are associated with the current SAS session.

    DICTIONARY.MACROS contains information about currently defined macro variables (both automatic and user-created).

    47. (D) The KEEP statement causes a DATA step to write only the variables listed in the KEEP statement to one or moredata sets.

    The KEEP statement applies to all data sets that are created within the same DATA step.

    The KEEP statement is only available in the DATA step.

    48. (A) In a compressed data set, SAS appends new observations to the end of the data set by default. If you delete an

    observation within the data set, empty disk space remains in its place. However, it is possible to track and reusefree space within the data set when you delete or update observations.

    The SAS REUSE= system option and the REUSE= data set option specify whether or not SAS reuses space when observations

    are added to a compressed data set. If you set the REUSE= data set option to YES in a DATA statement, SAS tracks and

    reuses space in the compressed data set that is created in that DATA step. If you set the REUSE= system option toYES, SAS tracks and reuses free space in all compressed data sets that are created for the remainder of the currentSAS session.

    49. (D) The CALL statement invokes a CALL routine. The syntax is as follows:

    CALL routine( parameter-1);

    The routine specifies the name of the SAS CALL routine that you want to invoke. The parameter is a piece ofinformation to be passed to or returned from the routine.

    In this instance, we’re using the SYMPUT routine. The SYMPUT routine assigns DATA step information to a macrovariable. The syntax is as follows:

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    23/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej GuntaCALL SYMPUT(argument-1,argument-2);

    argument-1 specifies a character expression that identifies the macro variable that is assigned a value. If the macrovariable does not exist, the routine creates it.

    argument-2 specifies a character constant, variable, or expression that contains the value that is assigned.

    In this example, we are using a variable name GROUP, to create macro variables with the value of SUM  for the same

    observation. What this does is create a macro variable A with a value of 765, a macro variable B with a value of 123,and a macro variable C  with a value of 564.

    Note: When you use the SYMPUT routine to create a macro variable in a DATA step, the macro variable is not actuallycreated and assigned a value until the DATA step is executed. Therefore, you cannot successfully reference a macrovariable that is created with the SYMPUT routine by preceding its name with an ampersand within the same DATA step inwhich it is created.

    50. (B) The FILENAME statement can be used to associate a fileref  with a single raw data file. However, as it is in this

    instance, it can also be used to concatenate raw data files by assigning a single fileref  to the raw data files thatyou want to combine. The syntax is as follows:

    FILENAME  fileref  (‘external-file1’ ‘external-file2’ ... ‘external-filen’); 

    Where fileref  is any SAS name that is eight characters or fewer, and external-file is the physical name of anexternal file. The physical name is the name that is recognized by the operating environment. (i.e.

    C:/folders/myfolders/)

    When the fileref is specified in an INFILE statement, each raw data file that has been referenced is sequentiallyread into the data set using an INPUT statement.

    Note: If you are not familiar with the content and structure of your raw data files, you can use PROC FSLIST to viewthem.

    51. The SAS data sets ONE and TWO are given below:

    ONE TWO

    COMMON X COMMON Y------ -- ------ --

    A 10 A 1A 13 A 3

    A 14 B 4B 9 B 2C 8 C 5C 14

    The following SAS data step is submitted:

    DATA COMBINE;

    MERGE ONE TWO;BY COMMON;

    RUN;

    Which one of the following represents the data values stored in data set COMBINE?

    A. OBS COMMON X Y1 A 10 12 A 13 3

    3 A 14 3

    4 B 9 45 B 9 26 C 8 5

    7 C 14 5

    B. OBS COMMON X Y1 A 10 1

    2 A 13 3

    3 B 9 44 C 8 5

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    24/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej Gunta

    C. OBS COMMON X Y

    1 A 10 12 A 13 13 A 14 1

    4 A 10 35 A 13 3

    6 A 14 3

    7 B 9 48 B 9 2

    9 C 8 510 C 14 5

    D. OBS COMMON X Y1 A 10 1

    2 A 13 3

    3 B 14 44 B 9 25 C 8 5

    52. Which one of the following techniques concatenates data in SAS?

    A. The DATA step with a COMBINE statementB. The APPEND procedure

    C. The INTERSECT operator in the SQL procedureD. The DATA step with a MERGE statement

    53. Which SET statement option names a variable that contains the number of the observation to read during the currentiteration of the DATA step?

    A. NOBS=POINTOBSB. POINT=POINTOBSC. OBS=POINTOBSD. KEY=POINTOBS

    54. Which one of the following programs contains a syntax error?

    A. PROC SQL;SELECT PRODUCT.*, COST.UNITCOST, SALES.QUANTITY

    FROM PRODUCT P, COST C, SALES SWHERE P.ITEM=C.ITEM AND P.ITEM=S.ITEM;

    QUIT;

    B. PROC SQL;SELECT PRODUCT.*, COST.UNITCOST, SALES.QUANTITYFROM PRODUCT, COST, SALES

    WHERE PRODUCT.ITEM=COST.ITEM AND PRODUCT.ITEM=SALES.ITEM;

    QUIT;

    C. PROC SQL;

    SELECT P.*, C.UNITCOST, S.QUANTITY

    FROM PRODUCT AS P, COST AS C, SALES AS SWHERE P.ITEM=C.ITEM AND P.ITEM=S.ITEM;QUIT;

    D. PROC SQL;

    SELECT P.*, C.UNITCOST, S.QUANTITYFROM PRODUCT, COST, SALES

    WHERE PRODUCT.ITEM=COST.ITEM AND PRODUCT.ITEM=SALES.ITEM;QUIT;

    55. Which SQL procedure deletes rows from the data set CLASS?

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    25/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej GuntaA. PROC SQL;

    ALTER FROM CLASS DELETE

    WHERE AGE < (SELECT STOP_AGE FROM THRESHOLD);QUIT;

    B. PROC SQL;MODIFY TABLE CLASS DELETE

    WHERE AGE < (SELECT STOP_AGE FROM THRESHOLD);

    QUIT;

    C. PROC SQL;SELECT *

    FROM CLASSWHERE AGE < (SELECT STOP_AGE FROM THRESHOLD);

    QUIT;

    D. PROC SQL;DELETE FROM CLASS

    WHERE AGE < (SELECT STOP_AGE FROM THRESHOLD);QUIT;

    56. The following SAS program is submitted:

    PROC DATASETS LIB=TESTDATA;

    MODIFY ONE;LABEL NUM=’Number’; FORMAT NUM 4.;

    QUIT;

    Which one of the following SQL codes produces the same results as the above DATASETS procedure?

    A. PROC SQL;

    ALTER TABLE TESTDATA.ONE

    MODIFY NUM (FORMAT=4. LABEL=’Number’); QUIT;

    B. PROC SQL;

    ALTER TABLE TESTDATA.ONEMODIFY NUM FORMAT=4. LABEL=’Number’; 

    QUIT;

    C. PROC SQL;

    MODIFY TABLE TESTDATA.ONEALTER NUM FORMAT=4. LABEL=’Number’; 

    QUIT;

    D. PROC SQL;MODIFY TABLE TESTDATA.ONE

    NUM FORMAT=4. LABEL=’Number’; QUIT;

    57. The following SAS program is submitted:

    %LET TEST=ONE;%LET ONE=TWO;

    %LET TWO=THREE;

    %LET THREE=LAST;%PUT What displays is &&&&&TEST;

    What is written to the SAS log?

    A. What displays is LASTB. What displays is ONEC. What displays is THREE

    D. What displays is TWO

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    26/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej Gunta58. The data set ONE is given below:

    NAME SALARY----- ------

    Hans 200

    Maria 205Jose 310Ariel 523

    The following output is desired:

    SALARY BONUS------ -----200 20

    205 20.5310 31523 52.3

    The following SAS program is submitted:

    PROC SQL;< insert SQL clause here >

    FROM ONE;QUIT;

    Which SQL procedure clause completes the program and generates the desired output?

    A. SELECT SALARY, SALARY*.10 COLUMN=’BONUS’ B. SELECT SALARY, SALARY*.10 LABEL=’BONUS’ C. SELECT SALARY, SALARY*.10 NAME=’BONUS’ D. SELECT SALARY, SALARY*.10 VAR=BONUS

    59. The following SAS program is submitted:

    %MACRO COLS1;NAME AGE;

    %MEND;

    %MACRO COLS2;HEIGHT WEIGHT;

    %MEND;PROC PRINT DATA=SASHELP.CLASS;

    < insert VAR statement here >RUN;

    Which VAR statement successfully completes the program and produces a report?

    A. VAR HEIGHT %COLS1;

    B. VAR %COLS1 HEIGHT;C. VAR %COLS1 %COLS2 HEIGHT;D. VAR %COLS2 %COLS1;

    60. The following SAS program is submitted:

    DATA TEMP;ARRAY POINTS{3,2} _TEMPORARY_ (10,20,30,40,50,60);

    SCORE=POINTS{2,1};RUN;

    Which one of the following is the value of the variable SCORE in the data set TEMP?

    A. 30B. 20C. 40D. 10

    51. (A) A MERGE statement joins observations from two or more SAS data sets into a single observation.

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    27/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej GuntaThe BY statement controls the operation of a SET, MERGE, MODIFY, or UPDATE statement in the DATA step and sets upspecial grouping variables.

    In this example, the BY statement joins the two data sets with the variable COMMON . So, in row one of both data sets,

    they each contain the common variable A. These overlap and the resulting, new record is “A 10 1”. The next row in

    each data set follows this as well. So, the second record in the new data set is “A 13 3”. The third one is not amatch. There is a third “A” observation in data set ONE, but it is lacking in data set TWO. So, what SAS does is dragdown the previous Y variable value to complete the record. Hence, “A 14 3”. 

    52. (B) To concatenate data sets is basically to stack one data set on top of the other.

    The APPEND procedure adds the observations from one SAS data set to the end of another SAS data set. PROC APPEND doesnot process the observations in the first data set. It adds the observations in the second data set directly to theend of the original data set. The syntax is as follows:

    PROC APPEND BASE=base-SAS-data-set  ;

    Where base-SAS-data-set names the SAS data set to which you want to append the observations. If this data set doesnot exist, then SAS creates it. At the completion of PROC APPEND, the value of base-SAS-data-set becomes the current(most recently created) SAS data set.

    SAS-data-set-to-append  names the SAS data set that contains the observations to add to the end of the base data set.If you omit this option, then PROC APPEND adds the observations in the current SAS data set to the end of the basedata set.

    FORCE forces PROC APPEND to concatenate the files in some situations in which the procedure would normally fail.

    Note: This differs from using a MERGE statement. A MERGE statement will join your data horizontally.

    53. (B) The POINT= option in the SET statement names a variable. You must use program statements to assign a value to

    this variable during execution of the DATA step, before execution of the SET statement. Also, the value of the POINT=variable should be a number that corresponds to an observation number in the input data set, and it should bedifferent each time the SET statement executes.

    54. (D) To mitigate the time required to type long table names, you may assign abbreviated table aliases in the FROM

    clause. Typically, it’s considered good programming practice to use the AS keyword to assign you’re alias, but it’snot required.

    The reason why option (D) is the correct choice is because the SELECT statement attempts to references variablesusing a table alias where one was not assigned.

    55. (D) To delete some or all of the rows in a table, use the DELETE statement. The syntax is as follows:

    DELETE FROM table-name ;

    Table-name specifies the name of the table in which rows will be deleted, and WHERE is optionally used to specify anexpression that subsets the rows to be deleted.

    If you want to delete only a subset of rows in the table, you must specify a WHERE clause or all rows in the tablewill be deleted.

    In this example, in order to perform successfully, the PROC SQL program abides by this logic and uses a subquery aspart of the WHERE clause.

    56. (B) The MODIFY statement changes the attributes of a SAS file and, through the use of subordinate statements, theattributes of variables in the SAS file.

    The DATASETS procedure is applying a label to the NUM variable as well as changing its format without affecting anyother aspect of the TESTDATA.ONE data set.

    The equivalent method using the SQL procedure involves the use of the ALTER TABLE clause.

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    28/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej Gunta57. (D) This program involves what’s known as the “Forward Re-Scan Rule”. 

    Whenever the macro processor encounters multiple ampersands or percentage signs preceding a token, the macroprocessor resolves two ampersands (&&) to one ampersand (&), and re-scans the reference.

    To re-scan a reference, the macro processor scans and resolves tokens from left to right from the point wheremultiple ampersands or percent signs are coded, until no more triggers can be resolved.

    In order to better grasp this, let’s evaluate our given problem in steps.

    %PUT What displays is &&&&&TEST;

    Here, we have five ampersands preceding the macro variable TEST . As has been said, two ampersands resolve to one.Once you’ve resolved two ampersands to one, imagine you drop that single ampersand to a level below your evaluationlevel for each pair.

    &&&&&TEST; So, two pair can be cancelled out and dropped down a level, but we are still left with &TEST which can beresolved to ONE.

    &&&&&TEST;  ONE

    If you’re able to evaluate as we’ve done, drop that resolved value (ONE) down to your row.

    &&ONE; Here, repeat the process as before. The two ampersands resolve to one ampersand and are dropped to a newlevel. However, this time there is not a single ampersand before the macro variable, so, it can’t be execut ed.

    &&ONE;  No execution

    So, once more, drop down your evaluated value (which remains ONE and repeat the process).

    &ONE; Here, there are no more multiple ampersands to resolve, so, you can simply resolve the macro variable itself.

    &ONE;  TWO

    Therefore, “What displays is TWO”. 

    58. (B) The SAS data set option LABEL= specifies the label to be displayed for the column.

    Note: This method does not create a column name; it merely labels the heading. Without assigning a column name, SAS

    assigns the default _TEMA001. The code could have been written SELECT SALARY, SALARY*.10 AS PORTION LABEL=’BONUS’ andit would have created the column PORTION  which possessed and displayed the label BONUS.

    59. (A) This is another example of a problem that needs particular attention.

    There are two macro programs: COLS1 and COLS2. The only thing within each program is a character string that getsprinted when the program is called.

    Notice, though, that each character string in each macro program contains a semicolon. Each available answer optionwill attempt to call one or both macro programs which print the contents of each in place where they’re called. 

    If you chose option (B), the semicolon, when printed, would cause an error. The result would look like: VAR NAME AGE;

    HEIGHT; and the additional semicolon is the root of the problem. The other options, (C) and (D), fail for the samereason.

    The only way that successfully executes is (A) because the macro program %COLS1 executes at the end of the VARstatement and SAS is able to ignore the additional semicolon.

    VAR HEIGHT NAME AGE;;

    60. (A) The ARRAY statement in this instance is an example of a multidimensional array. Its syntax is as follows:

    ARRAY array-name {rows,cols,…} ;

    As you can see, the array is divided into three rows and two columns. The initial values are filled into thattemporary array sequentially (Row1-Col1, Row1-Col2, Row2-Col1, etc.).

    The assignment statement creates the variable SCORE and it extracts a value from the temporary array. It goes to thesecond row, first column and extracts the value 30.

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    29/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej Gunta

    61. The SAS data set ONE consists of five million observations and has 25 variables.

    Which one of the following SAS programs successfully creates three new variables, TOTREV, TOTCOST, and PROFIT andrequires the least CPU time to be processed?

    A. DATA TWO;SET ONE;

    WHERE TOTREV > 1000;TOTREV=SUM(PRICE*QUANTITY);

    TOTCOST=SUM(FIXED,VARIABLE);PROFIT=SUM(TOTREV,TOTCOST);

    RUN;

    B. DATA TWO;SET ONE;TOTREV=SUM(PRICE*QUANTITY);

    TOTCOST=SUM(FIXED,VARIABLE);PROFIT=SUM(TOTREV,TOCOST);

    IF TOTREV > 1000;

    RUN;

    C. DATA TWO;

    SET ONE;TOTREV=SUM(PRICE*QUANTITY);

    WHERE TOTREV > 1000;TOTCOST=SUM(FIXED,VARIABLE);PROFIT=SUM(TOTREV,TOTCOST);

    RUN;

    D. DATA TWO;SET ONE;

    TOTREV=SUM(PRICE*QUANTITY);IF TOTREV > 1000;

    TOTCOST=SUM(FIXED,VARIABLE);

    PROFIT=SUM(TOTREV,TOTCOST);RUN;

    62. What is the purpose of the SASFILE statement?

    A. It requests that a SAS data set be opened and loaded into SAS memory one variable at a time

    B. It requests that a SAS data set be opened and loaded into SAS memory one page at a timeC. It requests that a SAS data set be opened and loaded into SAS memory one observation at a timeD. It requests that a SAS data set be opened and loaded into SAS memory in its entirety

    63. Which one of the following statements about compressed SAS data sets is always true?

    A. New observations are added to the end of the SAS data set

    B. Each observation is treated as a single string of bytesC. Each observation occupies the same number of bytes

    D. An updated observation is stored in its original location

    64. The SAS data set ONE is given below:

    REP COST

    ----- ----SMITH 200SMITH 400

    JONES 100

    SMITH 600JONES 100

    The following SAS program is submitted:

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    30/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej GuntaPROC SQL;

    SELECT REP, AVG(COST) AS AVERAGE

    FROM ONEGROUP BY REP

    < insert SQL procedure clause here >QUIT;

    The following output is desired:

    REP AVERAGE----- -------JONES 100

    Which SQL procedure clause completes the program and generates the desired output?

    A. WHERE CALCULATED AVERAGE > (SELECT AVG(COST) FROM ONE);

    B. HAVING AVG(COST) > (SELECT AVG(COST) FROM ONE);C. WHERE AVG(COST) > (SELECT AVG(COST) FROM ONE);D. HAVING AVG(COST) < (SELECT AVG(COST) FROM ONE);

    65. Consider the following SAS log:

    239 DATA SASUSER.RANCH SASUSER.CONDO / VIEW=SASUSER.RANCH;230 SET SASUSER.HOUSES;

    231 IF STYLE=’RANCH’ THEN OUTPUT SASUSER.RANCH; 

    232 ELSE IF STYLE=’CONDO’ THEN OUTPUT SASUSER.CONDO; 233 RUN;NOTE: DATA STEP view saved on file SASUSER.RANCH.

    NOTE: A stored DATA STEP view cannot run under a different operating system.234

    235 PROC PRINT DATA=SASUSER.CONDO;ERROR: File SASUSER.CONDO.DATA does not exist.

    236 RUN;NOTE: The SAS System stopped processing this step because of errors.

    Which one of the following explains why the PRINT procedure fails?

    A. The view SASUSER.RANCH must be processed before SASUSER.CONDO is createdB. SASUSER.CONDO is a stored DATA step program

    C. A second VIEW=SASUSER.CONDO option was omitted on the DATA statement

    D. A SAS data file and SAS data view cannot be created in the same DATA step

    66. Which one of the following options is available for SAS macro debugging?

    A. MLOGIC

    B. MDEBUGC. MSGLEVELD. MAUTOSOURCE

    67. The following SAS program is submitted:

    %LET FIRST=YOURNAME;%LET LAST=FIRST;

    %PUT &&&LAST;

    Which one of the following is the result in the log of the %PUT statement?

    A. &FIRST

    B. YOURNAMEC. &YOURNAMED. FIRST

    68. Which one of the following options controls the page size of a SAS data set?

    A. BUFSIZE=B. BUFNO=

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    31/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej GuntaC. PAGESIZE=D. SIZE=

    69. The following SAS program is submitted:

    %MACRO LOOP;

    DATA ONE;%DO i=1 %TO 3;

    VAR&i=&i;

    %END;RUN;%MEND;%LOOP

    After this program is executed; the following is written to the SAS log:

    (LOOP): Beginning execution

    (LOOP): %DO loop beginning; index variable i; start value is 1; stop value is 3; by value is 1

    (LOOP): %DO loop index variable i is now 2; loop will iterate again(LOOP): %DO loop index variable i is now 3; loop will iterate again

    (LOOP): %DO loop index variable i is now 4; loop will iterate again(LOOP): Ending execution

    Which SAS system option displays the notes in the SAS log?

    A. MACROB. SYMBOLGENC. MLOGICD. MPRINT

    70. Assume today is Tuesday, July 23, 2002. Which of the following statements submitted at the beginning of a SAS sessionassigns the value Tuesday, July 23, 2002 to the macro variable START?

    A. %LET START=%SYSFUNC(%TODAY(),WEEKDATE.);

    B. %LET START=TODAY(), FORMAT=WEEKDATE.;

    C. %LET START=TODAY(),WEEKDATE.;D. %LET START=%SYSFUNC(TODAY(), WEEKDATE.);

    61. (D) First, understand that SAS evaluates code line by line sequentially. Without knowing anything else besides that,you can eliminate option (A) because it is attempting to apply a WHERE clause with an expression to a variable thatdoesn’t even exist in the data set. Therefore, SAS will clearly return an error and the program will fail.

    The next thing to understand is a fundamental difference between WHERE statements and the subsetting IF statement.Normally, when you’re attempting to subset data, the WHERE statement is more efficient because it can evaluate data

    in the buffer before it decides whether or not to pass it along to the program data vector (PDV). On the other hand,

    the subsetting IF statement must wait until the data has entered the PDV before it can be evaluated based onprescribed conditions.

    The catch in this instance is that a WHERE statement can only select observations from SAS data sets, whereas the IF

    statement can select records from external files, observations from SAS data sets, observations created with an INPUT

    statement, or, in this case, observations based on the value of a computed or derived variable.

    Because TOTREV is a created variable, the WHERE statement is unable to subset it in the same DATA step, and theprogram fails.

    This leaves you with only options (B) and (D) to consider. Both would accomplish the task, but option (B) does not

    attempt to subset until after it’s already created the other two variables (TOTCOST and PROFIT). Therefore, it’s moreefficient to evaluate the subsetting IF and decide whether or not to pass on the record immediately after TOTREV hasbeen created instead of creating all three variables and then discarding it.

    62. (D) The SASFILE statement holds an entire SAS data file in memory so that the data is available to multiple program

    steps. Keeping the data file open reduces open/close operations, including the allocation and freeing of memory forbuffers.

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    32/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej Gunta

    63. (B) Compressed data files treat an observation as a single string of bytes by ignoring variable types and boundaries.

    Note: Options (A), (C), and (D) refer to uncompressed data file structures.

    64. (D) In order to further subset observations within a GROUP BY clause, you must use a HAVING clause. Therefore, youcan instantly eliminate options (A) and (C).

    Both HAVING clauses in (B) and (D) compare the average COST of each group to the average COST of the entire table.However, only option (D) returns the observation that results in the desired output because the average COST forJONES was less than the average COST of the table.Jones was

    65. (A) 

    66. (A) The system option MLOGIC prints messages that indicate macro actions that were taken during macro execution. Thegeneral form is as follows:

    OPTIONS MLOGIC | NOMLOGIC;

    Where NOMLOGIC  is the default setting, and specifies that messages about macros are not printed to the SAS log duringmacro execution. MLOGIC  specifies that messages about macro actions are printed to the log during macro execution.

    Note: Option (B), MDEBUG , isn’t even a SAS option. Option (C) MSGLEVEL is a system option that concerns index

    creation. Option (D), MAUTOSOURCE, is a system option that causes the macro processor to search the autocalllibraries for a member with the requested name when a macro name is not found in the WORK library.

    67. (B) This program involves what’s known as the “Forward Re-Scan Rule”. 

    Whenever the macro processor encounters multiple ampersands or percentage signs preceding a token, the macroprocessor resolves two ampersands (&&) to one ampersand (&), and re-scans the reference.

    To re-scan a reference, the macro processor scans and resolves tokens from left to right from the point wheremultiple ampersands or percent signs are coded, until no more triggers can be resolved.

    In order to better grasp this, let’s evaluate our given problem in steps. 

    %PUT &&&LAST;

    Here, we have three ampersands preceding the macro variable LAST . As has been said, two ampersands resolve to one.

    Once you’ve resolved two ampersands to one, imagine you drop that single ampersand to a level below your evaluationlevel for each pair.

    &&&LAST; So, one set of ampersands can be cancelled out and dropped down a level, but we are still left with &LASTwhich can be resolved to FIRST .

    &&&LAST;  FIRST

    &FIRST; Here, there are no more multiple ampersands to resolve, so, you can simply resolve the macro variable itself.

    &FIRST;  YOURNAME

    Therefore, the result of the %PUT statement is YOURNAME.

    68. (A) The page size is the amount of data that can be transferred for a single I/O operation to one buffer. The page

    size is a permanent attribute of the data set and is used when the data set is processed.

    A larger page size can speed up execution time by reducing the number of times SAS has to read from or write to thestorage medium. However, the improvement in execution time comes at the cost of increased memory consumption.

    Note: Be sure not to confuse the DATA set option BUFSIZE= with the system option PAGESIZE=. The system optionPAGESIZE specifies the number of lines that compose a page of SAS output.

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    33/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej Gunta69. (C) The MLOGIC option prints messages that indicate macro actions that were taken during macro execution. When the

    MLOGIC system option is in effect, the information that is displayed in SAS log messages includes: the beginning ofmacro execution, the results of arithmetic and logical macro operations, and the end of macro executions.

    Note: The system option MACRO is automatically enabled at the startup of the SAS system. It can be disabled andprevent SAS from executing macro language statements, calls, or variable references with the NOMACRO system option.

    SYMBOLGEN  specifies whether the results of resolving macro variable references are written to the SAS log fordebugging.

     MPRINT  specifies whether SAS statements generated by macro execution are traced for debugging.

    70. (D) You may immediately eliminate options (B) and (C). Without the %SYSFUNC function, each value of those macrovariables are considered to be character strings.

    The %SYSFUNC function makes it possible to execute most SAS functions from within a macro.

    71. The following SAS program is submitted:

    %LET NAME=Patel’s Restaurant; 

    Which one of the following statements avoids problems associated with the unbalanced quotation mark?

    A. %LET NAME=Patel%’s Restaurant; 

    B. %LET NAME=%STR(Patel’s Restaurant); 

    C. %LET NAME=Patel%STR(‘)s Restaurant; D. %LET NAME=%STR(Patel%’s Restaurant); 

    72. The data set ONE is given below:

    SALARY------200

    205523

    The following SAS program is submitted:

    PROC SQL;

    SELECT *FROM ONE

    < insert WHERE expression here >;QUIT;

    The following output is desired:

    SALARY------

    200205523

    Which WHERE expression completes the program and generates the desired output?

    A. WHERE Salary IS NOT

    B. WHERE Salary NE MISSINGC. WHERE Salary IS NOT MISSINGD. WHERE Salary NE NULL

    73. The following SAS program is submitted:

    DATA VIEW=SASUSER.RANCH;

    DESCRIBE;RUN;

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    34/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej GuntaWhat is the result?

    A. The program retrieves the SAS source code that creates the view and places it in the output windowB. The program creates a DATA step view called SASUSER.RANCH and places the program code in the current editor window

    C. The program retrieves the SAS source code that creates the view and places it in the SAS logD. The program creates a DATA step view called SASUSER.RANCH and places it in the SAS log

    74. Which of the following is true about the COMPRESS=YES data set option?

    A. It is most effective with numeric data that represents large numeric valuesB. It is most effective with character data that contains patterns, rather than simple repetitionsC. It is most effective with character data that contains repeated charactersD. It uses the Ross Data Compression method to compress numeric data

    75. The data sets ONE and TWO are given below:

    ONE TWOID NAME ID SALARY

    --- ----- --- ------

    112 Smith 213 150000243 Wei 355 45000457 Jones 523 75000

    The following SAS program is submitted:

    DATA COMBINE;

    MERGE ONE TWO;BY ID;

    RUN;

    Which SQL procedure produces the same results?

    A. PROC SQL;

    CREATE TABLE COMBINE AS

    SELECT COALESCE(ONE.ID, TWO.ID) AS ID, NAME, SALARYFROM ONEFULL JOIN

    TWO ON ONE.ID=TWO.ID;QUIT;

    B. PROC SQL;

    CREATE TABLE COMBINE ASSELECT ONE.ID, NAME, SALARYFROM ONEINNER JOIN

    TWO ON ONE.ID=TWO.ID;

    QUIT;

    C. PROC SQL;

    CREATE TABLE COMBINE AS

    SELECT COALESCE(ONE.ID, TWO.ID) AS ID, NAME, SALARYFROM ONE, TWO

    WHERE ONE.ID=TWO.ID;QUIT;

    D. PROC SQL;

    CREATE TABLE COMBINE ASSELECT ONE.ID, NAME, SALARY

    FROM ONEFULL JOIN

    TWO WHERE ONE.ID=TWO.ID;QUIT;

    76. Which one of the following SAS programs displays the descriptor portion of each data set stored in the SASUSERlibrary?

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    35/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej GuntaA. PROC DATASETS LIB=SASUSER._ALL_;

    QUIT;

    B. PROC DATASETS LIB=SASUSER;CONTENTS DATA=ALL;

    QUIT;

    C. PROC DATASETS LIB=SASUSER;

    CONTENTS DATA=_ALL_;QUIT;

    D. PROC DATASETS LIB=SASUSER.ALL;QUIT;

    77. The following SAS program is submitted:

    OPTIONS REUSE=YES;DATA SASUSER.REALESTATE (COMPRESS=CHAR);

    SET SASUSER.HOUSES;RUN;

    What is the effect of the REUSE=YES system option?

    A. It tracks and recycles free space

    B. It allows users to access the same SAS data set concurrentlyC. It allows updates in placeD. It allows a permanently stored SAS data set to be replaced

    78. The following SAS program is submitted:

    %LET VALUE=.5;%LET ADD=5;%LET NEWVAL=%EVAL(&VALUE + &ADD);

    Which one of the following is the resulting value of the macro variable NEWVAL?

    A. .5 + 5

    B. 5.5C. 5D. Null

    79. The data sets ONE and TWO are given below:

    ONE TWO

    YEAR QTR BUDGET YEAR QTR SALES---- --- ------ ---- --- -----

    2001 3 500 2001 4 3002001 4 400 2002 1 6002002 1 700

    Th following SAS program is submitted:

    PROC SQL;

    SELECT ONE.*, SALESFROM ONE, TWO;

    QUIT;

    Which one of the following reports is generated?

    A. YEAR QTR BUDGET SALES2001 3 500 300

    2001 4 400 300

    2002 1 700 3002001 3 500 6002001 4 400 600

    2002 1 700 600

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    36/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej GuntaB. YEAR QTR BUDGET SALES

    2001 3 500 300

    2001 4 400 3002002 1 700 600

    C. YEAR QTR BUDGET SALES2001 3 500 .

    2001 4 400 300

    2002 1 700 600

    D. YEAR QTR BUDGET SALES2001 4 400 3002002 1 700 600

    80. The following are values of the variable STYLE from the SAS data set SASUSER.HOUSES:

    STYLE--------

    RANCHSPLIT

    SPLIT

    CONDOTWOSTORYRANCH

    CONDOSPLITSPLIT

    The following SAS program is submitted:

    PROC SQL NOPRINT;SELECT DISTINCT STYLE

    INTO :STYLES SEPARATED BY “ “ 

    FROM SASUSER.HOUSESORDER BY STYLE;

    QUIT;

    Which one of the following is the value of the resulting macro variable?

    A. RANCH SPLIT CONDO TWOSTORY RANCH SPLIT SPLIT

    B. CONDO RANCH RANCH SPLIT SPLIT SPLIT TWOSTORYC. RANCH SPLIT CONDO TWOSTORYD. CONDO RANCH SPLIT TWOSTORY

    71. (D) The %STR function is used to mask (or quote) tokens during compilation so that the macro processor does not

    interpret them as macro-level syntax. That is, the %STR function hides the normal meaning of a semicolon and otherspecial tokens and mnemonic equivalents of comparison or logical operators so that they appear as constant text.

    In this example, without the %STR function, SAS would read the apostrophe as a single quote and scan for the second,closing quote.

    Note: You can achieve the same result as option (D) with the following syntax:

    %LET NAME=Patel%STR(%’)s Restaurant; 

    72. (C) When evaluating missing values as part of a WHERE clause in PROC SQL, you must invoke the IS condition. Thesyntax is as follows:

    Sql-expression IS  NULL | MISSING 

    Note: In addition to option (C), the following clause would have accomplished the same feat:

    WHERE Salary IS NOT NULL;

  • 8/18/2019 Advanced SAS 9 ExamPrep SritejGunta

    37/60

    Advanced SAS 9 Exam Prep: A00-212 | Prepared for Sritej Gunta73. (C) Before this code was written, a DATA step view had to have been created previously similar to the one below:

    DATA SASUSER.RANCH / VIEW=SASUSER.RANCH;INFILE ;

    ;RUN;

    What the code in question 73 does is invoke the DESCRIBE statement. What the DESCRIBE statement does is write a copyof the source code (above) to the SAS log.

    74. (C) The COMPRESS=YES data set option is particularly useful when your data set contains many values that haverepeated characters or binary zeros.

    In character data, the most frequently encountered repeated value is the blank. Long text fields, such as commentsand addresses, often contain repeated blanks.

    75. (A) The MERGE statement in SAS joins two or more SAS data sets into a single observation. In this instance, none ofthe BY variable values match, so the observations will be interleaved with each other, resulting in missing valuesfor each observation in the new table in either the NAME or SALARY  column.

    The method to achieve a similar result in PROC SQL is the FULL JOIN . A full outer join retrieves both matched rowsand nonmatching rows from both tables.

    Because both tables contain the column ID, you need to implement the COALESCE function. The syntax is as follows:

    SELECT COALESCE(column-1)

    Where column-1 through column-n are the names of two or more columns to be overlaid. The COALESCE function requires

    that all arguments have the same data type.

    Column-alias is a temporary name for the coalesced column. The alias cannot contain any spaces. If another clause inthe SELECT statement, such as an ORDER BY clause, references the coalesced column, a column alias must be specified.

    76. (C) PROC DATASETS is a SAS procedure used to manage data sets. The CONTENTS statement in PROC DATASETS allows you toview the descriptor portion of a data set.

    _ALL_ is a special SAS name list that, when used in place of the SAS-data-set-name, lists all data sets within theidentified library with the libref .

    Note: You may also use the CONTENTS procedure to accomplish the same task.

    77. (A) The SAS REUSE= system option and the REUSE= data set option specify whether or not SAS reuses space whenobservations are added to a compressed data set. If you set the REUSE= data set option to YES in a DATA statement,SAS tracks and reuses space in the compressed data set that is created in that DATA step.

    78. (D) The character operand + is found within the %EVAL function. This produces a null result because the %SYSEVALFfunction is the only macro function that can evaluate arithmetic or logical expressions using floating point ormissing values.

    Imitate the following to correct the code:

    %LET NEWVAL=%SYSEVALF(&VALUE + &ADD);

    The resulting value of the macro variable NEWVAL would be the expected 5.5.

    79. (A) When