1. Does SAS have a function for calculating factorials?
Ans:
DATA FACTORIAL;
DO N = 1 TO 12;
FACTORIAL_N = FACT(N);
OUTPUT;
END;
FORMAT FACTORIAL_N COMMA12.;
RUN;
PROC PRINT DATA=FACTORIAL NOOBS;
TITLE "Listing of Data Set FACTORIAL";
RUN;
[Link] is the smallest length for a numeric and character variable respectively ?
Ans: 2 bytes and 1 byte.
3. What is the largest possible length of a macro variable?
4. What is the difference between a FUNCTION and a PROC?
Ans: The fundamental difference between
functions and procedures is that a function expects the
argument values to supplied across an observation in a
SAS data set. Procedures expects one variable value per
observation.
Exp:
data average ;
set temp ;
avgtemp = mean( of T1 - T24 ) ;
run ;
proc sort ;
by month ;
run ;
proc means ;
by month ;
var avgtemp ;
run ;
5. Can you execute macro within another macro? If so, how would SAS know
where the current macro ended and the new one began?
6. When reading a NON SAS external file what is the best way of reading the file?
Ans: Use the INPUT statement with pointer control - ex: INPUT @1 dateextr
mmddyy8. etc.
7. If you use a SYMPUT in a DATA step, when and where can you use the macro
variable?
Ans:
%let sweek =-1;
data _null_;
bd= INTNX('WEEK',today(), &sweek,'B');
edate = put(bd+6, date9.);
bdate = put (bd, date9.);
call symput ("edatec",edate);
call symput ("bdatec",bdate);
run;
Proc print data =account_perf;
Title " Weekly report from &bdatec to &edatec";
var &varlist;
run;
8. What are SYMGET and SYMPUT?
Ans:
SYMPUT provides a way to turn DATA step variables into macro variables, and
SYMGET does the converse,
grabbing macro variable values and assigning them to DATA step variables.
Comparisons
SYMGET returns values of macro variables during program execution,
whereas the SYMPUT function assigns values that are produced by a
program to macro variables during program execution.
SYMGET accepts fewer types of arguments than the RESOLVE function.
SYMGET resolves only a single macro variable. Using RESOLVE may result
in the execution of macros and further resolution of values.
SYMGET is available in all SAS programs, but SYMGETN is available only in
SCL programs.
9. Describe the validation procedure? How would you perform the validation for
TLG as well as analysis data set?
[Link] are some of the differences between a WHERE and an IF statement?
Answer: Major differences include:
o IF can only be used in a DATA step
o Many IF statements can be used in one
DATA step
o Must read the record into the program data
vector to perform selection with IF
o WHERE can be used in a DATA step as well
as a PROC.
o A second WHERE will replace the first
unless the option ALSO is used
o Data subset prior to reading record into
PDV with WHERE