Base SAS Interview Questions and Answers
by Pritha Radhakrishnan, on Jul 29, 2023 12:19:48 PM
Q1. What is Base SAS?
Ans: Base SAS is the foundation of the SAS programming language, providing data management, analysis, and reporting capabilities.
Q2. What are the different data types in SAS?
Ans: The main data types in SAS are numeric, character, and date/time.
Q3. How do you create a new variable in SAS?
Ans: A new variable can be created using the DATA step and the SET or INPUT statements.
Q4. What is the difference between WHERE and IF statements in SAS?
Ans: The WHERE statement is used for subsetting observations, while the IF statement is used for conditional processing within a DATA step.
Q5. How can missing values be handled in SAS?
Ans: Missing values can be handled using the MISSING function, the IF-THEN statement, or the COALESCE function.
Q6. What are SAS formats and informats?
Ans: SAS formats are used to control the appearance of data values, while informats are used to read data values into SAS variables.
Q7. Explain the difference between PROC MEANS and PROC SUMMARY.
Ans: Both procedures calculate summary statistics, but PROC MEANS provides additional features like handling missing values and producing percentile statistics.
Q8. How can you sort data in SAS?
Ans: Data can be sorted using the SORT procedure or by using the SORT statement within a DATA step.
Q9. What is the purpose of the RETAIN statement in SAS?
Ans: The RETAIN statement is used to retain the value of a variable across iterations of the DATA step.
Q10. How do you merge datasets in SAS?
Ans: Datasets can be merged using the MERGE statement or the SQL JOIN operation.
Q11. What is the purpose of the LENGTH statement in SAS?
Ans: The LENGTH statement is used to assign the length of a variable in SAS.
Q12. How can you debug SAS programs?
Ans: SAS programs can be debugged using various techniques such as the PUT statement, the DEBUG option, and the SAS log.
Q13. What are SAS macro variables?
Ans: SAS macro variables are created and manipulated using the %LET statement and are used to store and retrieve values during macro processing.
Q14. How can you create a macro variable in SAS?
Ans: A macro variable can be created using the %LET statement or by assigning a value using a DATA step or a PROC SQL statement.
Q15. What is the purpose of the ODS statement in SAS?
Ans: The ODS (Output Delivery System) statement is used to control the output destination and format of SAS output.
Q16. Explain the difference between a SAS dataset and a SAS view.
Ans: A SAS dataset is a physical file stored on disk, while a SAS view is a virtual dataset that is defined by a SAS program and does not store data itself.
Q17. How can you handle duplicate observations in SAS?
Ans: Duplicate observations can be identified and handled using the SORT procedure with the nodupkey or nodup option.
Q18. What is a BY statement in SAS?
Ans: The BY statement is used to group data and perform calculations within each group using procedures like PROC SORT and PROC MEANS.
Q19. What are the different types of SAS functions?
Ans: SAS functions include numeric, character, date/time, and conversion functions, among others.
Q20. How can you create a permanent SAS dataset?
Ans: A permanent SAS dataset can be created using the DATA step and the LIBNAME statement to assign a permanent library.
Q21. How can you import data from an external file into SAS?
Ans: Data can be imported from an external file into SAS using the INFILE statement or the IMPORT procedure.
Q22. What is a SAS data library?
Ans: A SAS data library is a collection of one or more SAS datasets that are stored together under a common name or location.
Q23. How can you export data from SAS to an external file?
Ans: Data can be exported from SAS to an external file using the FILE statement or the EXPORT procedure.
Q24. What is the purpose of the PROC SQL procedure in SAS?
Ans: PROC SQL provides a SQL interface within SAS and allows you to manipulate and query data using SQL syntax.
Q25. How can you generate random numbers in SAS?
Ans: Random numbers can be generated in SAS using the RAND function or by using the RANUNI or RANNOR functions for uniform or normal distributions, respectively.