SQL & SAS Interview Questions with Answers - Bindu M
SQL Questions & Answers:
Q1. What is the difference between WHERE and HAVING clause?
A: WHERE is used to filter rows before grouping, while HAVING is used to filter groups after the
GROUP BY clause.
Q2. What is the difference between INNER JOIN and LEFT JOIN?
A: INNER JOIN returns only the matching rows from both tables. LEFT JOIN returns all rows from
the left table and matching rows from the right; if no match, NULLs are returned for the right table.
Q3. What is a Window Function in SQL?
A: A Window Function performs a calculation across a set of rows related to the current row.
Example: ROW_NUMBER(), RANK(), DENSE_RANK(), etc.
Q4. What is the purpose of GROUP BY in SQL?
A: GROUP BY is used to group rows that have the same values in specified columns and allows
aggregate functions like COUNT, SUM to be applied to each group.
Q5. How do you find duplicate records in a table?
A:
SELECT column1, COUNT(*)
FROM table_name
GROUP BY column1
HAVING COUNT(*) > 1;
SAS Questions & Answers:
Q1. What is the difference between PROC MEANS and PROC FREQ?
A: PROC MEANS is used to calculate statistics for numeric variables (mean, median, etc.), while
PROC FREQ is used to calculate frequency counts of categorical variables.
Q2. How do you merge two datasets in SAS?
A:
DATA merged;
MERGE data1 data2;
BY id;
RUN;
Q3. What is a SAS Macro?
A: A SAS Macro is used to automate repetitive tasks. It allows dynamic generation of SAS code
using variables and macro functions.
Q4. How do you handle missing values in SAS?
A: Use functions like NMISS() or IF conditions to filter or replace missing values. Example: IF var = .
THEN var = 0;
Q5. How do you import a CSV file into SAS?
A:
PROC IMPORT DATAFILE='/path/file.csv'
OUT=mydata
DBMS=CSV
REPLACE;
RUN;