Top 50 SAS Interview Questions You Must Prepare In 2021

Bhavitha Thippanna
Edureka
Published in
10 min readMar 29, 2019

SAS is the most popular Data Analytics tool in the market. This blog is the perfect guide for you to learn all the concepts required to clear a SAS interview. We have segregated the questions based on the difficulty levels and this will help people with different expertise levels to reap the maximum benefit from our blog. SAS Interview Questions blog will be a one-stop resource from where you can boost your interview preparation.

Before moving to SAS interview questions, let us understand why SAS is important. SAS is easy to learn and provides an easy option (PROC SQL) for people who already know SQL. SAS is on par with all leading tools including R & Python when it comes to handling huge amount of data and options for parallel computations. Globally, SAS is the market leader in available corporate jobs. In India, SAS controls about 70% of the data analytics market share compared to 15% for R. If you are planning to step your foot in Data Analytics, now is the right time for you to start with SAS Certification Training. Now, let us move on to some of the most important SAS interview questions that can be asked in your SAS interview.

SAS Interview Questions

1. List down the reasons for choosing SAS over other data analytics tools.

Answer: We will compare SAS with the popular alternatives in the market based on the following aspects:

2. What is SAS?

Answer: SAS (Statistical Analytics System)

  • SAS is a software suite for advanced analytics, multivariate analyses, business intelligence, data management and predictive analytics
  • It is developed by SAS Institute.
  • SAS provides a graphical point-and-click user interface for non-technical users and more advanced options through the SAS language.

3. What are the features of SAS?

Answer: The following are the features of SAS:

Figure: SAS Interview Questions — Features of SAS

  1. Business Solutions: SAS provides business analysis that can be used as business products for various companies to use.
  2. Analytics: SAS is the market leader in the analytics of various business products and services.
  3. Data Access & Management: SAS can also be use as a DBMS software.
  4. Reporting & Graphics: Hello SAS helps to visualize the analysis in the form of summary, lists and graphic reports.
  5. Visualization: We can visualize the reports in the form of graphs ranging from simple scatter plots and bar charts to complex multi-page classification panels.

4. Mention few capabilities of SAS Framework.

Answer: The following are the four capabilities in SAS Framework:

Figure: SAS Interview Questions — SAS Framework

  1. Access: As we can learn from the figure, SAS allows us to access data from multiple sources like an Excel file, raw database, Oracle database and SAS Datasets.
  2. Manage: We can then manage this data to subset data, create variables, validate and clean data.
  3. Analyze: Further, analysis happens on this data. We can perform simple analyses like frequency and averages and complex analyses including regression and forecasting. SAS is the gold standard for statistical analyses.
  4. Present: Finally we can present our analysis in the form of list, summary and graphic reports. We can either print these reports, write them to data file or publish them online.

5. What is the function of output statement in a SAS Program?

Answer: You can use the OUTPUT statement to save summary statistics in a SAS data set. This information can then be used to create customized reports or to save historical information about a process.

You can use options in the OUTPUT statement to

  1. Specify the statistics to save in the output data set,
  2. Specify the name of the output data set, and
  3. Compute and save percentiles not automatically computed by the CAPABILITY procedure.

6. What is the function of Stop statement in a SAS Program?

Answer: Stop statement causes SAS to stop processing the current data step immediately and resume processing statement after the end of current data step.

7. What is the difference between using drop = data set option in data statement and set statement?

Answer: If you don’t want to process certain variables and you do not want them to appear in the new data set, then specify drop = data set option in the set statement.

Whereas If want to process certain variables and do not want them to appear in the new data set, then specify drop = data set option in the data statement.

8. Given an unsorted data set, how to read the last observation to a new data set?

Answer: We can read the last observation to a new data set using end= data set option.

For example:

data work.calculus;
set work.comp end=last;
If last;
run;

Where calculus is a new data set to be created and comp is the existing data set. last is the temporary variable (initialized to 0) which is set to 1 when the set statement reads the last observation.

9. What is the difference between reading data from an external file and reading data from an existing data set?

Answer: The main difference is that while reading an existing data set with the SET statement, SAS retains the values of the variables from one observation to the next. Whereas when reading the data from an external file, only the observations are read. The variables will have to re-declared if they need to be used.

10. How many data types are there in SAS?

Answer: There are two data types in SAS. Character and Numeric. Apart from this, dates are also considered as characters although there are implicit functions to work upon dates.

11. What is the difference between SAS functions and procedures?

Answer: Functions expect argument values to be supplied across an observation in a SAS data set whereas a procedure expects one variable value per observation.

For example:

data average ;
set temp ;
avgtemp = mean( of T1 – T24 ) ;
run ;

Here arguments of mean function are taken across an observation. The mean function calculates the average of the different values in a single observation.

proc sort ;
by month ;
run ;
proc means ;
by month ;
var avgtemp ;
run ;

Proc means is used to calculate average temperature by month (taking one variable value across an observation). Here, the procedure means on the variable month.

12. What are the differences between sum function and using “+” operator?

Answer: SUM function returns the sum of non-missing arguments whereas “+” operator returns a missing value if any of the arguments are missing.

Example:
data mydata;
input x y z;
cards;
33 3 3
24 3 4
24 3 4
. 3 2
23 . 3
54 4 .
35 4 2
;
run;

data mydata2;
set mydata;
a=sum(x,y,z);
p=x+y+z;
run;

In the output, value of p is missing for 4th, 5th and 6th observation as:

a p
39 39
31 31
31 31
5 .
26 .
58 .
41 41

13. What are the differences between PROC MEANS and PROC SUMMARY?

Answer: PROC MEANS produces subgroup statistics only when a BY statement is used and the input data has been previously sorted (using PROC SORT) by the BY variables.

PROC SUMMARY automatically produces statistics for all subgroups, giving you all the information in one run that you would get by repeatedly sorting a data set by the variables that define each subgroup and running PROC MEANS. PROC SUMMARY does not produce any information in your output. So you will need to use the OUTPUT statement to create a new DATA SET and use PROC PRINT to see the computed statistics.

14. Give an example where SAS fails to convert character value to numeric value automatically?

Answer: Suppose value of a variable PayRate begins with a dollar sign ($). When SAS tries to automatically convert the values of PayRate to numeric values, the dollar sign blocks the process. The values cannot be converted to numeric values.

Therefore, it is always best to include INPUT and PUT functions in your programs when conversions occur.

15. How do you delete duplicate observations in SAS?

Answer: There are three ways to delete duplicate observations in a dataset:

  1. By using nodups in the procedureProc sort data=SAS-Dataset nodups;
    by var;
    run;

2. By using an SQL query inside a procedure

Proc sql;
Create SAS-Dataset as select * from Old-SAS-Dataset where var=distinct(var);
quit;

3. By cleaning the data

Set temp;
By group;
If first.group and last.group then
Run;

16. How does PROC SQL work?

Answer: PROC SQL is a simultaneous process for all the observations. The following steps happen when PROC SQL is executed:

  1. SAS scans each statement in the SQL procedure and check syntax errors, such as missing semicolons and invalid statements.
  2. SQL optimizer scans the query inside the statement. The SQL Optimizer decides how the SQL query should be executed in order to minimize run time.
  3. Any tables in the FROM statement are loaded into the data engine where they can then be accessed in memory.
  4. Code and Calculations are executed.
  5. Final Table is created in memory.
  6. Final Table is sent to the output table described in the SQL statement.

17. Briefly explain Input and Put function?

Answer: Input function — Character to numeric conversion- Input(source,informat)

put function — Numeric to character conversion- put(source,format)

18. What would be the result of the following SAS function (given that 31 Dec, 2000 is Sunday)?

Weeks = intck (‘week’,’31 dec 2000’d,’01jan2001’d);
Years = intck (‘year’,’31 dec 2000’d,’01jan2001’d);
Months = intck (‘month’,’31 dec 2000’d,’01jan2001’d);

Answer: Here, we will calculate the weeks between 31st December, 2000 and 1st January, 2001. 31st December 2000 was a Sunday. So 1st January 2001 will be a Monday in the same week. Hence, Weeks = 0

Years = 1, since both the days are in different calendar years.

Months = 1 ,since both the days are in different months of the calendar.

19. Suppose the variable address stores the following expression:

209 RADCLIFFE ROAD, CENTER CITY, NY, 92716

What would be the result returned by the scan function in the following cases?

a=scan(address,3);
b=scan(address,3,’,’);

Answer: a=Road; b=NY

20. What is the length assigned to the target variable by the scan function?

Answer: 200

21. Name few SAS functions?

Answer: Scan, Substr, trim, Catx, Index, tranwrd, find, Sum.

22. What is the work of tranwrd function?

Answer: TRANWRD function replaces or removes all occurrences of a pattern of characters within a character string.

23. Consider the following SAS Program

data finance.earnings;
Amount=1000;
Rate=.075/12;
do month=1 to 12;
Earned+(amount+earned)*(rate);
end;
run;

What would be the value of month at the end of data step execution and how many observations would be there?

Answer: Value of month would be 13

No. of observations would be 1

24. How do dates work in SAS data?

Data is central to every data set. In SAS, data is available in tabular form where variables occupy the column space and observations occupy the row space.

  • SAS treats numbers as numeric data and everything else falls under character data. Hence SAS has two data types numeric and character.
  • Apart from these, dates in SAS are represented in a special way compared to other languages.

Figure: SAS Interview Questions — SAS Dates

  • A SAS date is a numeric value equal to the number of days since January 1, 1960.
  • Apart from Date Values, there are many tools to work on dates such as informats for reading dates, functions for manipulating dates and formats for printing dates.

25. Consider the following SAS Program

data finance;
Amount=1000;
Rate=.075/12;
do month=1 to 12;
Earned+(amount+earned)*(rate);
output;
end;
run;

How many observations would be there at the end of data step execution?

Answer: 12

26. How do you use the do loop if you don’t know how many times you should execute the do loop?

Answer: We can use ‘do until’ or ‘do while’ to specify the condition.

27. What is the difference between do while and do until?

Answer: An important difference between the DO UNTIL and DO WHILE statements is that the DO WHILE expression is evaluated at the top of the DO loop. If the expression is false the first time it is evaluated, then the DO loop never executes. Whereas DO UNTIL executes at least once.

28. How do you specify the number of iterations and specific condition within a single do loop?

Answer:

data work;
do i=1 to 20 until(Sum>=20000);
Year+1;
Sum+2000;
Sum+Sum*.10;
end;
run;

This iterative DO statement enables you to execute the DO loop until Sum is greater than or equal to 20000 or until the DO loop executes 10 times, whichever occurs first.

29. What are the parameters of Scan function?

Answer: This is how the scan function is used.

scan(argument,n,delimiters)

Here, argument specifies the character variable or expression to scan,

n specifies which word to read, and

delimiters are special characters that must be enclosed in single quotation marks.

data mymerge;
merge mydata1 mydata2;
run;

If the observations do not match, then match merging is suitable

data mydata1;
input id class $;
cards;
1 Sa
2 Sd
2 Sp
3 Rd
4 Uj
;

data mydata2;
input id class1 $;
cards;
1 Sac
2 Sdf
3 Rdd
3 Lks
5 Ujf
;

data mymerge;
merge mydata1 mydata2;
by id
run;

I hope this set of SAS interview questions will help you in preparing for your interview. Further, I would recommend SAS Tutorial videos from Edureka to learn more.

If you wish to check out more articles on the market’s most trending technologies like Python, DevOps, Ethical Hacking, then you can refer to Edureka’s official site

Originally published at https://www.edureka.co on March 29, 2019.

--

--