Interview Types
Photo of candidates waiting for a job interview

Here is a list of top 50 SAS interview question and answer for 2021:

1.What is SAS?

Ans: SAS (Statistical analysis system) is an analytical software developed by the SAS institute. It is widely popular for data management, data analysis and reporting task. SAS is also used for data mining, multivariate analysis, Predictive analytics and business intelligence.

2.Difference between if and where in SAS

Ans:
IF statement used to create a subset of the input dataset by specifying conditions and operators, whereas WHERE statement is used for selecting observations and value by specifying conditions and operators. |
IF statement cannot be used in PROC procedures, The WHERE statement can be used in both PROC and DATA step
IF statement cannot be used to search for all similar character values that sound alike, WHERE statement can be used to search for all similar character values that sound alike
IF statement can be applied on automatic variables (_N_, First., Last. Variables) WHERE statement cannot be applied on automatic variables.

3.What is the other name for data preparation stage of knowledge discovery process SAS?

Ans: Data preparation stage is well known as data mining stage in which the processes includes like – Selection of data, Cleansing of data, Construction of new datasets, Integration of the new datasets with the already existing data sources, Formatting of the data to give it the right size and appearance.

4.What is PDV in SAS?

Ans: During the compilation phase SAS creates program data vector (PDV), which is a logical area in memory where SAS build a data set, one observation at a time.

5. How to create library in SAS?

Ans: SAS Library is created by using LIBNAME keyword along with valid SAS name, not more than 8 characters and the path with the name of the directory enclosed in quotation. Syntax-

LIBNAME mydata 'physical Path\directoryname'; Run;

6. What is SAS storage?
Ans:SAS data sets (tables), the default SAS storage format to store data of any granularity in the form of observations (rows) and variables (columns) and also descriptor information such as data types, column lengths, and the SAS engine is uses in the storage of data.

7. How to import data in SAS?

Ans: SAS PROC IMPORT procedure is used to read raw data from the source and writes it to a SAS data set. SAS Import procedure can read a variety of data file like EXCEL, CSV, delimited file(Tab, blank, comma).
Syntax

PROC IMPORT datafile =' physical Path\filename' DBMS=identifier OUT=SAS data set REPLACE; run;

8. How to install SAS?

Ans: SAS university edition which is free SAS software with limitations for individuals which can be download from the SAS website on a different operating systems like Windows, Linux and Mac. For setup and installation must have oracle virtual box and downloaded SAS University edition software in a folder. To configure we will import the SAS UA into Virtual box and share created folder with virtual box for launch.

9.What is SAS used for?

Ans : It is widely popular for data management, data analysis and reporting task. SAS is also used for data mining, multivariate analysis, Predictive analytics and business intelligence.

10. What is data step in SAS?

Ans: Data step is very important statement is SAS which is use to create, modify, making subset, merging, updating of existing data set and also to compute data values.

11. How many ways to create macro variables in SAS?

Ans: SAS macros variable can be created by multiple ways like- By using %LET, By defining Macro parameters, By iterative %DO statement, By using the INTO in PROC SQL and also by using the CALL SYMPUTX routine.

12. How to create a library in SAS?

Ans: SAS Library is created by using LIBNAME keyword along with valid SAS name not more than 8 character and the path and name of the directory enclosed in quotation. Syntax-

LIBNAME mydata 'physical Path'; Run;

13. How to delete formats in SAS?

Ans:

To delete assigned formats from dataset we will use PROC Datasets statement with Lib= option and Modify statement with the dataset name.

Syntax

<!-- wp:paragraph -->
<p><strong>Syntax</strong> - PROC DATASETS LIB=work;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>MODIFY New;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>FORMAT _all_;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>INFORMAT _all_;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>RUN;</p>
<!-- /wp:paragraph -->

14. How to create a dataset in SAS?

Ans: Data set is created by using data step statement along with set statement, The data set name must be began with letter or underscore and not more then 32 character long. Syntax

Data mydataset; Set newdataset; Run;

15. What is ODS in SAS?

Ans: ODS stand for Output delivery system which convert SAS output data in user define report format output like HTML, PDF, EXCEL RTF. Syntax are- ODS outputtype File =’ path and file name’ ; PROC step statement ; run; ODS outputtype close;

16. What is input buffer in SAS?

Ans: The input buffer is created at the beginning of the compilation phase which is used to hold the raw data.

17. How to read csv file in SAS?

Ans: SAS PROC IMPORT procedure is a convenient way to import/Read CSV data file into SAS data set.

Syntax

PROC IMPORT datafile =' physical Path\filename.CSV' DBMS=CSV OUT=SAS data set REPLACE; Run;

18. How to create a table in SAS?

Ans: All one-dimension, two-dimension or three- dimension tables can be created by using PROC Tabulate statement. TABULATE can computes and add a variety of statistics and results in the tables and creates professional looking table.

19. How to find missing values in SAS?

Ans: SAS PROC MEANS procedure is use for descriptive statistical analysis for the numeric variable in a data set. In the mean procedure we can include the keyword called NMISS, which will results the number of missing values in numeric variables of the same dataset.
Syntax

PROC MEANS data= mydata; NMISS; Run;

20. How to create permanent dataset in SAS?

Ans: SAS permanent dataset must be follow the two level name, for that we have to create SAS libarary first by using Libname statement and assign that created library name with data setname in prefix.

21. How to remove duplicate rows in SAS?

Ans: Duplicate rows in a dataset can be remove during the PROC SORT procedure, by using NODUP option is data set name

22. How to import sas dataset into SAS?

Ans: SAS dataset is import by using SET statement. The following syntax is use to import or copy SAS dataset. DATA mydata; SET newdata; RUN;

23. How to debug SAS program?
Ans: Debugging is the process of identifying and resolving errors from a program. It could be Syntax error, Semantic error, Logic error or Data error. We could debug the program by testing each part of the program and there syntax, BY testing program with small datasets, By reading log and identifying warning and errors, By searching of missing semicolon, By adding PUT statement into the program.

24. What is data lines in SAS?

Ans: DATALINES is a statement used with an INPUT statement in DATA step to read data that we enter directly in the program.

25. How to increase font size in SAS?

Ans: Changing SAS font size could be done manually in three programming interface- SAS studio, SAS Windowing environment, and SAS Enterprises guide. In SAS studio Open the “more application options” menu, and select “Preferences.” then new box will appear on the screen. Choose “Editor” from the list on the left, then look for a dropdown menu labeled “Font Size.”

In widowing environment click in the enhanced editor window, Select “Tools” from the toolbar, and click “Options” then “Enhanced Editor. Double check that the enhanced editor window is active. A new box will appear then choose the “Appearance” tab, then use the “Size” dropdown to select your font size. In SAS Enterprises guide Select “Program” from the tool bar, then click “Editor Options. A new box will appear on your screen, choose the “Appearance” tab, then use the “Size” dropdown to select your font size.

26. How to sort dataset in SAS?

Ans: To sort the dataset, the PROC SORT procedure is use in ascending or descending order, by default the sort is ascending.

SYNTAX

PROC SORT data=mydata OUT=outdata; RUN;

27. What functions does SAS perform?

Ans: SAS has a wide variety of in built functions which help in analyzing and processing the data. Specific Function in SAS are categorized in Character, Numeric and Date. Few common and important SAS character functions are SUBSTR, TRIM, COMPRESS, SCAN. Useful Numeric function are- SUM, COUNT, ROUND, MIN, MAX and also we can use function in Date like- DATE, TODAY, MDY etc.

28. What is the basic structure of a SAS base program?

Ans: SAS program line began with a keyword DATA or PROC step with dataset name and each line end with a semicolon. To end the SAS program we will use the RUN statement at the end with semicolon.

29. What is PDV?

Ans: During the compilation phase SAS creates program data vector (PDV), which is a logical area in memory where SAS build a data set, one observation at a time.

30. What is the difference between nodupkey and the nodup options?

Ans: SAS nodupkey and nodup key words are use to remove the duplicate during the PROC SORT procedure in sorting the dataset. In which nodupkey check and eliminates observation with duplicate BY variables values comparing whereas nodup checks for and eliminates duplicate observations by comparing all the variables

31. Name types of category in which SAS Informats are placed

Ans:SAS Informats are used to read or input data from external files in three informats categories character, numeric, and date/time.

32. List out some key concept of SAS

Ans:
1-SAS program can consist of a DATA step, a PROC step, or any combination of DATA and the PROC steps.
2- DATA steps typically create or modify SAS data sets.
3-PROC steps are pre- written routines that enables you to analyze and process the data in the SAS data set and to present the data in the form of a report.
4- PROC steps sometimes create new SAS data sets that contain the results of the procedure like-Proc sort, Proc Transpose.
5-A SAS statement usually begins with a ‘SAS keyword’ and always ends with a semicolon.
6-Each time a step is executed, SAS generates a log of the processing activities and the results of the processing.
7-The SAS log collects messages about the processing of the SAS programs and about any errors that occur.

33. What is factor analysis?

Ans: Factor analysis is a statistical method use to investigate relationships and variability among observed, correlated variables in terms of a potentially lower number of unobserved variables .

34. How SAS treats the DSD delimiters?

Ans: In SAS infile statement the DSD option specifies that when data values are enclosed in quotation marks, delimiters within the value are treated as character data. When we specify DSD, SAS treats two consecutive delimiters as a missing value and removes quotation marks from character values.

35. What are the ways to do a “table lookup” in SAS?

Ans: A table lookup technique used to determine the value of a variable in the primary table to determine the value of another variable that is present in a secondary table. There are a number of techniques for performing these table lookup- DATA Step Merges, SQL Joins, Using Formats and also Using Indexes

36. What are the difference between CEIL and FLOOR functions in SAS?

Ans: CEIL is a numeric function which returns the smallest integer that is greater than or equal to the argument, whereas FLOOR Returns the largest integer less than or equal to a numeric value expression.

37. What is the use of STOP statement?

Ans: The STOP statement causes SAS to stop processing the current DATA step immediately and resume processing statements after the end of the current DATA step. The STOP statement can be used alone or in an IF-THEN statement or SELECT group.

38. What is SLIBREF?

Ans: SLIBREF=server-libref which specifies the libref that is used by the remote session to identify the SAS data library when no physical name is specified and the local session’s libref is different from the remote session’s libref.

39. What is the use of the %include statement?

Ans: The %INCLUDE statement causes SAS to read from the file that is referenced by SASTERM.

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

Ans:

1- SAS has been the undisputed market leader in commercial analytics space.

2- SAS offers huge array of statistical functions and has good GUI (Enterprise Guide & Miner) for people to learn quickly also provides easy option (PROC SQL) for people who already know SQL.

3- It provides awesome technical support and has dedicated customer service along with the community.

41. Mention few capabilities of SAS Framework.

Ans: The following are the capabilities of SAS Framework : 1- Access data from multiple sources, 2- Management of access data, 3- Simple to Advance level Data Analysis, 4- Reporting in the form of list, summary and graphs.

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

Ans: To select the last observation of given data set we first sort the data set using BY statement using proc sort procedure, the DATA step creates two temporary variables for each variable in the BY statement. The names of these variables are FIRST. Variable and its value 1 for the first observation in each BY group and LAST. Variable has the value 1 for the last observation in each BY group. Now by using IF condition the last record in BY group can read.

Syntax

<!-- wp:paragraph -->
<p><strong>Syntax-</strong> proc sort data=sashelp.cars out= new;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>by type;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>run;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>data new1;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>set new;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>by type;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>if last. Type;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>run;</p>
<!-- /wp:paragraph -->

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

Ans: SUM is a numeric function for aggregating numeric variables where as “+” is a Arithmetic operator for adding two or more variables. SUM function returns the sum of non missing and missing arguments where as “+” operator returns a missing values (arguments) if any of the values are missing.

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

Ans: In SAS iterative DO Loop statement starts with DO XYZ = start TO stop and END statement marks the end of the loop, where xyz is an index variable with start and stop values, which specifies the number of iterations of a Do statement which is fixed and for conditionally executing do loops the DO WHILE and DO UNTIL statements help us to execute do loop on whether a condition is true of false.

Syntax

<!-- wp:paragraph -->
<p><strong>Syntax- Do Loop without condition </strong>data A;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>do I = 1 to 4;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>y = I**2;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>output;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>end;</p>
<!-- /wp:paragraph -->

Syntax

<!-- wp:paragraph -->
<p><strong>Syntax- Do Loop with condition </strong>data Test;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>money = 10000;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>newCounter = 0;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>do until (money > 0);</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>money = money - 1000;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>newCounter = newCounter + 1;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>end;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>run;</p>
<!-- /wp:paragraph -->

45. What is the difference between One to One Merge and Match Merge? Give an example.

Ans: One-to-one merging combines observations from two or more SAS data sets into a single observation in a new data set where as Match-merging combines observations from two or more SAS data sets into a single observation in a new data set according to the values of a common variable. To perform a one-to-one merge, use the MERGE statement without a BY statement where as In match-merge, use a BY statement immediately after the MERGE statement.

Example- One-to-One data New3;

merge New1 New3;

run; Example- Match-Merge data New3;

merge New1 New3;

By Id ; run;

46. What is interleaving in SAS?

Ans:

Interleaving combines individual sorted SAS data sets into one big sorted data set based on the variables listed in a BY statement.

Syntax

<!-- wp:paragraph -->
<p>DATA three;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>set one two;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>by year;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>run;</p>
<!-- /wp:paragraph -->

47. How to create list output for crosstabulations in proc freq?

Ans: To create list output we use PROC FREQ procedure along with tables statement and variable names.

Syntax

PROC FREQ data=mydata; Tables Var1*Var2/list; Run;

49. What is the difference between CLASS statement and BY statement in proc means?

Ans: Both CLASS and BY statement is use to categorizes/grouping the variable values on ascending or descending order. In Class statement we don’t need to sort the dataset where as in BY variable statement the dataset must be sorted first.

50. What can be the size of largest dataset in SAS?

Ans: The maximum file size for a SAS data set is 2 gigabytes.

0

LEAVE A REPLY

Please enter your comment!
Please enter your name here

four + 1 =