Você está na página 1de 16

SAS Macros Questions

Srikanth Potukuchi
January 19, 2015
1) The macro facility is a
and customizing SAS code.

processing facility for automating

(a) text
(b) word
(c) excel
(d) None
2) Macro programs support conditional construction of SAS code.
(a) True
(b) False
3) Macro programs support repetitive generation of SAS code.
(a) True
(b) False
4) Macro programs support dynamic data-driven generation of
SAS code.
(a) True
(b) False
5) When you submit a SAS program,it is copied to a memory
stack.
location called the
(a) output
(b) input
(c) subset
(d) pointer

Srikanth Potukuchi

6) When SAS code is in the input stack, a component of SAS


called the word scanner does the following:
(a) reads the text in the input stack, character by character, left to right, top
to bottom; and breaks the text into fundamental units called tokens
(b) reads the text in the input stack, character by character, right to left, top
to bottom; and breaks the text into fundamental units called tokens
(c) reads the text in the input stack, character by character, left to right, bottom
to top; and breaks the text into fundamental units called tokens
(d) reads the text in the input stack, character by character, left to right, top
to bottom; and breaks the text into fundamental units called brokens
7) The word scanner recognizes four classes of tokens: name,special,literal,
and number tokens.
(a) True
(b) False
8)Are blanks tokens?
(a) Yes
(b) No
9) A macro trigger is either an ampersand (&) or percent sign (%)
followed by a nonblank character.
(a) True
(b) False
10) Macro variables are stored in a memory area called the
table.

symbol

(a) local
(b) global
11) Macro variables in the global symbol table store numeric tokens as text.
(a) True
(b) False

Page 2

Srikanth Potukuchi

12)The value of the macro variable created by the % LET statement, %let sum=3+4, is 7.
(a) True
(b) False
13)Which WHERE statement is correct?
(a) where City=&office;
(b) where City=&office;
(c) where City=&office;
14)Which system option writes macro variable values to the SAS
log as they are resolved?
(a) options all ;
(b) options symdel;
(c) options symbolgen;
(d) options nosymbolgen;
15)A macro variable reference can appear anywhere,but additional
syntax is sometimes required. Which of the following might pose a
problem?
(a) Leading text
(b) Adjacent macro variable references
(c) Trailing text
(d) None
(e) All

Page 3

Srikanth Potukuchi

16)Is trailing text a problem here?


%let year=2000;
%let month=jan;
%let var=sale;
proc chart data=orion.y&year&month;
hbar week / sumvar=&var;
run;
proc plot data=orion.y&year&month;
plot &var*day;
run;
(a) Yes
(b) No
17)
%let lib=orion;
%let graphics=g;
libname &lib S: / workshop;
proc &graphics.chart data=&lib.y&year&month;
hbar week / sumvar=&var;
run;
proc &graphics.plot data=&lib.y&year&month;
plot &var*day;
run;
The above program gives an error. What solves the problem?
(a) Use another period after &lib
(b) Use another period after &graphics
(c) both
(d) None
18) %put %upcase(angel);
(a) ANGEL
(b) Angel
(c) angel
(d) unknown

Page 4

Srikanth Potukuchi

19) %let name=angel;


%put %upcase(&name);
(a) ANGEL
(b) Angel
(c) angel
(d) unknown
20) %put %upcase(%substr(&name,1,1));
(a) ANGEL
(b) Angel
(c) A
(d) unknown
21) %put %upcase(%mymacro);
(a) ANGEL
(b) Angel
(c) A
(d) unknown
22)What is the value of x after %LET statement execution?
%let x=%substr(ABCD,2,1);

(a) A
(b) B
(c) C

Page 5

Srikanth Potukuchi

23) Consider the SAS log:


28 %put x=2+2;
x=2+2
29 %put x=%eval(2+2);
Which of the following is true?
(a) x=.
(b) x=2
(c) x=4
(d) unknown
24) Consider the SAS log:
28 %put &=syslast;
SYSLAST=WORK.ORDERS
29 %put DSN=%sysfunc(propcase(&syslast));
Which of the following is true?
(a) DSN=.
(b) DSN=work.orders
(c) DSN=WORK.ORDERS
(d) DSN=Work.Orders
25)You can use macro functions to do which of the following:
(a) manipulate text
(b) execute SAS functions
(c) manipulate SAS data set variables
(d) perform arithmetic calculations

Page 6

Srikanth Potukuchi

26) The %STR function masks & and % characters.


(a) True
(b) False
27) The %NRSTR function masks & and % characters.
(a) True
(b) False
28) Given:
%let fullname=Anthony Miller;
In order to extract the first initial and last name, and put them together
into a new variable as A.Miller; which of the following work?
(a) %let newname=%substr(&fullname,1,1).%scan(&fullname,2);
%put &newname;
(b) %let initial=%substr(&fullname,1,1);
%let last=%scan(&fullname,2);
%let newname=&initial..&last;
%put &newname;
(c) None
(d) Both
29)This is a fill in the blank question! Assign your birthdate to a
macro variable
30)This is a fill in the blank question! Issue a %PUT statement
that writes the day of the week that you were born.
31)This code defines the Time macro,which displays the current
time.
%macro time;
%put The current time is %sysfunc
(time(),timeampm.).;
%mend time;

Page 7

Srikanth Potukuchi

Which of the following calls the above macro?


(a) %time;
(b) %time
(c) &time
(d) &time;
32)Storing a macro permanently requires two steps.
Step 1 options mstored sasmstore=orion;
Step 2 %macro time / store source;
What does MSTORED option do?
(a) Enables storage of compiled macros in a temporary library.
(b) Enables storage of compiled macros in a permanent library.
(c) Stores the macro source code with the compiled code.
(d) Designates a permanent library to store compiled macros.
33)This is a fill in the blank question!
To view the text generated by macro execution, specify the
34) We want to a macro that issues the current time of the day
with the TIMEAMPM.format.
%macro currtime;
(time(),timeAMPM.)
currtime;
The two blanks are:
(a) %func,%mend
(b) %sysfunc,%macro
(c) %sysfunc,%mend
(d) %symdel,%mend
35) To verify macro compilation, specify the MCOMPILENOTE=ALL
option.
(a) True
(b) False

Page 8

option.

Srikanth Potukuchi

36) The macro parameter name should be


options mcompilenote=all;
%macro customers(
);
proc print data=orion.customer dim;
var Customer Name;
where Customer Group contains &type;
run;
%mend customers;
37) How to call the above macro with the parameter value of
Catalog?
(a) %customers(type=Catalog)
(b) %customers(Catalog);
(c) %customers(Catalog)
(d) %customers(type=catalog);
38) What is the value of foot after execution of the DATA step?
data null ;
call symputx(foot,No Internet orders);
%let foot=Some Internet orders;
run;
(a) No Internet orders
(b) Some Internet orders
39) Edit the CALL SYMPUTX routines to format values. Display
DAT as a date such as 11/21/2009.Display AVG as a number with
dollar signs and no decimal places.
call symputx(dat, put(date,
));
call symputx(avg, put(amount/number,

));

Page 9

Srikanth Potukuchi

40) Consider the following:


%let custID=9;
proc print data=orion.order fact;
where customer ID&custID;
var order date;
title Customer Name: &name9;
run;
We want to create an order history for custID 4. How many program changes
are required?
(a) 1
(b) 3
(c) 2
(d) None
41) Consider the following:
%let custID=9;
%let name9=Joe;
%put &name&custID;
run;
How many times are the macro variables scanned in the %PUT statement?
(a) 1
(b) 3
(c) 2
(d) None
42)Which technique creates macro variables during execution time?
(a) %LET statement
(b) SYMPUTX routine
(c) INTO clause
(d) both b and c

Page 10

Srikanth Potukuchi

43) What happens when you submit the following:


%macro reports;
%daily
%if &sysday=Friday then %weekly;
%mend reports;
(a) No error
(b) Error: Expected %THEN statement not found.
(c) Error:Expected %THEN statement not found.A dummy macro will be compiled.
(d) Some warning
44)The %IF-%THEN statement is valid in a DATA step where as
a IF-THEN statement is valid in Macro definition.
(a) True
(b) False
45) Which statement correctly creates an index variable named i?
(a) %do &i=1 %to 10;
(b) %do &i=1 to 10;
(c) %do i=1 %to 10;
(d) %do i=1 to 10;
46) Given the symbol table, what is the value of &&SITE&COUNT?
SPLIT
SPLIT
SPLIT
SPLIT
SPLIT
SPLIT
SPLIT
SPLIT
SPLIT
SPLIT

SITE4 IL
DATA orion.customer
COUNT 7
VAR country
SITE3 DE
SITE2 CA
SITE1 AU
SITE7 ZA
SITE6 US
SITE5 TR

Page 11

Srikanth Potukuchi

(a) DE
(b) AU
(c) ZA
(d) CA
47) Given the symbol table, what is the value of &&&SITE&COUNT?
SPLIT
SPLIT
SPLIT
SPLIT
SPLIT
SPLIT
SPLIT
SPLIT
SPLIT
SPLIT

SITE4 IL
DATA orion.customer
COUNT 7
VAR country
SITE3 DE
SITE2 CA
SITE1 AU
SITE7 ZA
SITE6 US
SITE5 TR

(a) DE
(b) AU
(c) ZA
(d) CA
(e) None
48) Given the symbol table, what is the value of &&&SITE&&COUNT?
SPLIT
SPLIT
SPLIT
SPLIT
SPLIT
SPLIT
SPLIT
SPLIT
SPLIT
SPLIT

SITE4 IL
DATA orion.customer
COUNT 7
VAR country
SITE3 DE
SITE2 CA
SITE1 AU
SITE7 ZA
SITE6 US
SITE5 TR

Page 12

Srikanth Potukuchi

(a) DE
(b) AU
(c) ZA
(d) CA
(e) None
49)How many local symbol tables are created when macro A is
called and begins to execute?
%macro a(value=);
%b
%mend a;
%macro b;
%put The value to write is: &value.;
%put user ;
%mend b;
%a(value=Today is Monday)

(a) 1
(b) 3
(c) 2
(d) None
50)Identify in which symbol table the macro variable dog is located?
%let dog=Paisley;
%macro whereisit;
%put My dog is &dog;
%mend whereisit;
%whereisit
(a) Global Symbol Table
(b) Local Symbol Table
(c) None

Page 13

Srikanth Potukuchi

51)Identify in which symbol table the macro variable dog is located?


%macro whereisit;
%let dog=Paisley;
%put My dog is &dog;
%mend whereisit;
%whereisit
(a) Global Symbol Table
(b) Local Symbol Table
(c) None
52)Identify in which symbol table the macro variable dog is located?
%macro whereisit(dog);
%put My dog is &dog;
%mend whereisit;
%whereisit(Paisley)
(a) Global Symbol Table
(b) Local Symbol Table
(c) None
53) The %LOCAL statement adds one or more macro variables to
the local symbol table with null values.
(a) True
(b) False
54) The %LOCAL statement has no effect on variables already in
the local table.
(a) True
(b) False
55)The
statement deletes one or more user-defined macro
variables from the global symbol table.
(a) % all ;
(b) %symdel;
(c) %symbolgen;
(d) %nosymbolgen;

Page 14

Srikanth Potukuchi

56) Consider the SAS log:


26 %put &=syslast;
SYSLAST=WORK.ORDERS
27 %put DSN=%scan(&syslast,2,.)
Which of the following is true?
(a) DSN=.
(b) DSN=ORDERS
(c) DSN=WORK.ORDERS
(d) unknown

Page 15

Srikanth Potukuchi

References
R
[1] Jim Simon & Linda Mitterling, SAS
Macro Language 1: Essentials. SAS
Institute Inc., NC, 2013.

Page 16

Você também pode gostar