4 Tricky SAS Interview Questions for Aspiring Data Scientists

Introduction

If you‘re an aspiring data scientist or analytics professional, you‘ve likely seen the increasing buzz around open-source languages like R and Python. But despite the hype, SAS remains one of the most widely used tools for statistical analysis and data science in the business world.

Consider these stats:

  • SAS is used by more than 83,000 business, government and university sites in 147 countries
  • 92 of the top 100 companies on the 2018 Fortune Global 500 are SAS customers
  • SAS has more than 50% market share in advanced analytics

Sources: SAS fact sheet, IDC advanced analytics study

While there‘s no denying that Python and R are powerful tools, SAS continues to be the go-to for many large enterprises. This is especially true in regulated industries like banking and pharma.

So what makes SAS so great? For one, it‘s highly capable of data triangulation – combining data from multiple sources to answer business questions. It also has powerful data manipulation and analytical capabilities in an easy-to-learn syntax. This makes it accessible to users of varying technical abilities.

Beyond the basics, SAS also offers a suite of high-performance data mining and machine learning tools. This includes neural networks, support vector machines, random forests and gradient boosting. The ability to handle big data and build complex models makes SAS very relevant in today‘s AI-focused world.

As a data scientist, being able to demonstrate your SAS chops is extremely valuable. So let‘s dive into some of the most challenging SAS questions you might face in a data science interview. We‘ll cover the concepts with an AI expert lens, offering statistics and unique insights throughout.

Interview Question Walkthroughs

1. Merging datasets

Combining data is fundamental in any analysis. But as we covered earlier, merging in SAS is trickier than it looks, especially with many-to-many relationships.

Interviewers like this question because it tests whether you understand the difference between DATA step merges and SQL joins. Misunderstanding this can lead to inaccurate results and faulty business decisions.

How big an issue is this? An InfoWorld study estimated that bad data costs businesses over $600 billion annually. Data preparation and integration accounts for much of this cost.

As data scientists dealing with ever-increasing volumes and sources of information, we must be hyper-vigilant about data integrity. Mastery of merging and combining data in SAS is a core competency.

2. Transposing data

Transposing wide data to long or vice versa is another key skill. We previously looked at using PROC TRANSPOSE or a custom DATA step for this.

The tricky part is knowing which approach to use when. While PROC TRANSPOSE is more straightforward, there are times a DATA step is preferable for performance or flexibility reasons.

When dealing with big data, a DATA step transpose can be much more efficient. Restructuring 10 million rows using PROC TRANSPOSE might max out your memory, while a DATA step handles it in stride.

Another case for DATA steps is when you need to perform calculations or modifications to the data mid-transpose. PROC TRANSPOSE is fairly limited in this regard.

As an AI practitioner, you‘re likely dealing with huge, messy datasets. The ability to efficiently reshape data for your analytical needs is crucial. Impress your interviewer by discussing the nuances of each transposition method.

3. Passing values between steps

We touched on using macro variables to share values across DATA steps. This comes in very handy when you need to perform piecemeal processing of large datasets.

Here are some stats that highlight the need to be smart about data size:

  • The average company now manages over 160 terabytes of data (IBM)
  • Poor data quality costs the US economy $3.1 trillion per year (IBM)
  • Data scientists spend 60% of their time cleaning and organizing data (Forbes)

By processing and summarizing in chunks, you can greatly reduce runtime and system strain. Macro variables let you stitch it all together on the backend.

Another technique for passing values is to use SAS‘s BY-group processing statements. This tells SAS to perform operations separately for each unique grouping variable.

proc sort data=sales;
    by region;
run;

proc means data=sales noprint;  
    by region;
    var amount;
    output out=region_totals sum=total;
run;

data final_report;
    merge region_totals 
          region_goals;
    by region;
    if total < goal then status=‘Under‘;
    else status=‘Met‘;  
run;

Here the PROC MEANS summarizes sales by region and outputs regional totals. The final DATA step merges these totals with a goals dataset and computes the status for each region.

The interviewer is looking to see if you can piece together solutions to multi-part problems. Discuss how you break down a large task into manageable steps. Mention the importance of self-documenting code and diagnostic output when doing complex processing.

4. Subsetting with WHERE vs. IF

Earlier we explained the functional and efficiency differences between WHERE and IF statements. Interviewers often dig deeper on this to assess your knowledge of SAS data step processing.

A few key concepts to touch on:

  • WHERE is executed before the DATA step, IF is executed for each record within
  • Subsetting early with WHERE is more efficient than IF
  • WHERE can only reference input columns, IF can use new columns
  • Using an IF when a WHERE suffices is a common newbie mistake

Seasoned SAS programmers avoid unnecessary record processing at all costs. Imagine a 500 million row dataset where a DATA step IF is used instead of a WHERE. The difference could be significant.

In AI applications with terabyte-scale data, efficiency is mandatory. Algorithms like neural networks and random forests are highly iterative. Shaving even a second off each modeling step can save days overall.

Demonstrating a deep understanding of DATA step processing and efficiency techniques is a major asset. Talk through examples of optimizing a program. Mention techniques like:

  • Outsourcing heavy calculations to PROC steps
  • Using data views instead of physical tables
  • Leveraging format libraries
  • Compressing data

Bonus: Predictive modeling

Beyond the basics, interviewers may dig into your knowledge of SAS modeling procedures. A sample question:

"Describe how you would build a logistic regression model in SAS to predict customer churn."

Start by discussing data prep steps like:

  • Defining the binary target variable (churn yes/no)
  • Selecting and transforming input features
  • Splitting data into training, validation and test sets
  • Handling missing values and outliers

Then walk through the syntax:

proc logistic data=train outmodel=model;
    class category_var; 
    model churn (event=‘1‘) = var1 var2 var3 category_var / selection=stepwise;
    score data=validate out=scores;  
run;

Some key points:

  • The CLASS statement indicates categorical inputs
  • EVENT=‘1‘ in the MODEL statement identifies that customer churn=‘1‘ is the positive class
  • SELECTION=STEPWISE performs automated feature selection to find the best predictors
  • The SCORE statement applies the trained model to the validation data

Evaluating model performance is key. Mention using the ROCPLOT option to assess the sensitivity/specificity tradeoff. Also discuss lift and gain charts to measure the value-add over a random model.

For complex problems, talk about moving beyond standard logistic regression into techniques like:

  • Lasso and elastic net regularization (GLMSELECT)
  • Polynomial and spline basis functions (EFFECTPLOT)
  • Ensemble and meta-modeling approaches

Other Key SAS Skills

Beyond our interview questions, some other key SAS skills to highlight:

  • Working with unstructured and semi-structured data (text parsing, JSON, XML)
  • Graph and report generation (PROC SGPLOT, PROC TABULATE)
  • In-database and grid computing
  • Integration with open-source tools (Python, R, Hadoop)

The more you can position yourself as a well-rounded data professional, the better. Experience with a variety of data structures, analytical techniques, and delivery mechanisms is very attractive to employers.

Conclusion

SAS remains a powerful and entrenched tool in the business analytics space. As an aspiring data scientist, it behooves you to develop deep knowledge of this language.

But don‘t stop there. The data world is evolving rapidly and the tools are constantly changing. Keep learning and pushing the envelope. Explore how SAS can integrate with up-and-coming frameworks and architectures.

Some predictions on the future of SAS:

  • SAS Studio and Viya will overtake the traditional SAS 9 interface
  • More seamless integration with open-source tools (SWAT package, ability to code in Python/R/Lua and execute in SAS)
  • Increasing focus on cloud deployment and microservices architectures
  • Doubling down on AI and ML capabilities (e.g. DLPy deep learning API)
  • Tighter coupling with visual analytics for data storytelling

Exciting times ahead! As you continue your data science journey, remember that learning is a lifelong pursuit. Stay curious, hone your SAS craft, but keep your eyes to the horizon. The ability to evolve and adapt is what will make you truly invaluable.

What other SAS or general data science topics would you like us to cover? Drop a comment and let us know! And don‘t forget to subscribe to the Data Science Insiders email list for more great content like this.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Similar Posts