41. What are SYMGET and SYMPUT?
Ans: SYMPUT puts the value from a dataset into a macro variable where as
SYMGET gets the value from the macro variable to the dataset.
42. Which date function advances a date, time or datetime value by a given interval?
Ans: 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).
SAS Date Functions
43. How to count the number of intervals between two given SAS dates?
Ans: INTCK(interval,start-of-period,end-of-period) is an interval function that counts the number of intervals between two give SAS dates, Time and/or datetime.
44. Difference between SCAN and SUBSTR?
Ans: 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.
45. The following data step executes:
Text1 = “MICKEY MOUSE & DONALD DUCK”;
Text = scan(text1,2,’&’);
What will the value of the variable Text be?
Ans: * DONALD DUCK [(Leading blanks are displayed using an asterisk *]
46. For what purpose would you use the RETAIN statement?
Ans: A RETAIN statement tells SAS not to set variables to missing when going from the current iteration of the DATA step to the next. Instead, SAS retains the values.
47. When grouping is in effect, can the WHERE clause be used in PROC SQL to subset data?
Ans: No. In order to subset data when grouping is in effect, the HAVING clause must be used. The variable specified in having clause must contain summary statistics.
48. How to use IF THEN ELSE in PROC SQL?
Ans: PROC SQL;
WHEN WEIGHT BETWEEN 0 AND 50 THEN ’LOW’
WHEN WEIGHT BETWEEN 51 AND 70 THEN ’MEDIUM’
WHEN WEIGHT BETWEEN 71 AND 100 THEN ’HIGH’
ELSE ’VERY HIGH’
END AS NEWWEIGHT FROM HEALTH;
49. How to remove duplicates using PROC SQL?
Ans: Proc SQL noprint;
Create Table inter.Merged1 as
Select distinct * from inter.readin ;
50. How to count unique values by a grouping variable?
Ans: You can use PROC SQL with COUNT(DISTINCT variable_name) to determine the number of unique values for a column.