Friday, 6 February 2015

Most recently asked SAS Programming Interview Questions and Answers (Page 6)

26) What other SAS products have you used and consider yourself proficient in using?
Data _NULL_ statement, Proc Means, Proc Report, Proc tabulate, Proc freq and Proc print, Proc Univariate etc.

27) What is the significance of the ‘OF’ in X=SUM (OF a1-a4, a6, a9);
If don’t use the OF function it might not be interpreted as we expect. For example the function above calculates the sum of a1 minus a4 plus a6 and a9 and not the whole sum of a1 to a4 & a6 and a9. It is true for mean option also.

28) What do the PUT and INPUT functions do?
INPUT function converts character data values to numeric values.
PUT function converts numeric values to character values.
EX: for INPUT: INPUT (source, informat)
For PUT: PUT (source, format)

Note that INPUT function requires INFORMAT and PUT function requires FORMAT.

If we omit the INPUT or the PUT function during the data conversion, SAS will detect the mismatched variables and will try an automatic character-to-numeric or numeric-to-character conversion. But sometimes this doesn’t work because $ sign prevents such conversion. Therefore it is always advisable to include INPUT and PUT functions in your programs when conversions occur.

29) Which date function advances a date, time or datetime value by a given interval?
INTNX: INTNX function advances a date, time, or datetime value by a given interval, and returns a date, time, or datetime value.
Ex: INTNX(interval,start-from,number-of-increments,alignment)

INTCK: INTCK(interval,start-of-period,end-of-period) is an interval functioncounts the number of intervals between two give SAS dates, Time and/or datetime.
DATETIME () returns the current date and time of day.
DATDIF (sdate,edate,basis): returns the number of days between two dates.

30) What do the MOD and INT function do? What do the PAD and DIM functions do?
MOD: Modulo is a constant or numeric variable, the function returns the reminder after numeric value divided by modulo.
INT: It returns the integer portion of a numeric value truncating the decimal portion.
PAD: it pads each record with blanks so that all data lines have the same length. It is used in the INFILE statement. It is useful only when missing data occurs at the end of the record.
CATX: concatenate character strings, removes leading and trailing blanks and inserts separators.
SCAN: it returns a specified word from a character value. Scan function assigns a length of 200 to each target variable.
SUBSTR: extracts a sub string and replaces character values.
Extraction of a substring: Middleinitial=substr(middlename,1,1);
Replacing character values: substr (phone,1,3)=’433’;
If SUBSTR function is on the left side of a statement, the function replaces the contents of the character variable.
TRIM: trims the trailing blanks from the character values.

SCAN extracts words within a value that is marked by delimiters.
SUBSTR extracts a portion of the value by stating the specific location. It is best used when we know the exact position of the sub string to extract from a character value.
More Questions & Answers :-
Page1  Page2  Page3  Page4  Page5  Page6  Page7  Page8

No comments:

Post a Comment