InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
What do you mean by %Include and %Eval? |
|
Answer» %Include: If you run a program containing the %INCLUDE statement, the SAS System executes any statements or data lines that you bring into the program. Statements are executed immediately. Syntax: %INCLUDE source(s)</<SOURCE2> <S2=length> <option-list> >;Here,
%Eval: Integer arithmetic is used to evaluate arithmetic or logical expressions. %EVAL accepts only INTEGERS as operands in arithmetic expressions. Operands with floating-point values cannot be used in %EVAL arithmetic calculations. %SYSEVALF can be used in these cases. Syntax: %EVAL(arithmetic/logical-expression) Example: %let d=%eval(13+23);ConclusionHave you been preparing for a SAS INTERVIEW and wondering how you can succeed? This useful guide can HELP you prepare for it. We've compiled a list of the top 30+ SAS interview questions and answers that you're likely to be asked during your interviews. The questions have been specifically designed to familiarize you with the TYPE of questions you might ENCOUNTER during the interview. |
|
| 2. |
Explain what is INPUT and INFILE Statement. |
|
Answer» In SAS programming, USING an INFILE STATEMENT identifies an external file containing the data, WHEREAS using an INPUT statement describes the variables used. Syntax of INFILE: INFILE 'filename'; Syntax of INPUT: INPUT 'varname1' 'varname2'; Example: DATA readin INFILE TEST; INPUT ID Gender Score; Run; |
|
| 3. |
Name the command used for sorting in SAS programs? |
|
Answer» The PROC SORT command can be used to sort data in SAS. The command can be used for multiple VARIABLES within a program. It creates a new DATASET with sorting and keeps the original dataset unchanged. Syntax: PROC SORT DATA=original OUT=SORTED; BY variable_name;Here,
|
|
| 4. |
What do you mean by NODUP and NODUPKEY options and write difference between them? |
||||||||
|
Answer» PROC SORT in SAS enables the removal of duplicate values from a table primarily by utilizing TWO options:
NODUP VS NODUPKEY -
|
|||||||||
| 5. |
Explain different ways to remove duplicate values in SAS. |
|
Answer» Below are two ways to delete duplicate values in SAS:
The NODUPRECS (or NODUPREC or NODUP) option of PROC SORT identifies observations with identical values for all columns and REMOVES them from the output DATA set. Proc sort data=SAS-Dataset nodups; By varname; run;
PROC SQL can be used to remove duplicates. The DISTINCT keyword is used in the SELECT CLAUSE to ACCOUNT for duplicate observations. proc sql; create table New_dataset as select distinct * from Old_dataset where var=distinct(var); quit; |
|
| 6. |
Explain the usage of trailing . |
|
Answer» Occasionally, multiple observations need to be CREATED from a single RECORD of raw data. In ORDER to specify how SAS will READ such a record, you can use the double trailing at-sign ( or "double trailing @"). By using a double trailing , SAS is told to "hold the line more strongly". A double trailing sign () directs SAS not to advance to another input record, but to hold the CURRENT input record for the next input statement. It is important to note that the single trailing @ does not hold an input record for subsequent Iterations of the data step. A trailing "@" indicates that an input record will only be held for this iteration of the data step (until the processing returns or gets back to the top of the data step), or that it will be passed to the next INPUT statement without a single trailing "@". |
|
| 7. |
How do you specify the number of iterations and specific conditions within a single do loop? |
|
Answer» The code below illustrates how to specify the number of iterations and SPECIFIC conditions within a single do loop. The ITERATIVE DO statement executes the DO loop until the Sum is greater than or EQUAL to 50000, or until the DO loop has executed 10 times, WHICHEVER comes first. data Scaler; do i=1 to 50 until (Sum>=50000); Year+1; Sum+5000; Sum+Sum*.10; END; run; |
|
| 8. |
What is the importance of the Tranwrd function in SAS. |
|
Answer» TRANRWD, when APPLIED to a character string, replaces or eliminates all occurrences of a substring. By USING TRANWRD, you can scan for words (or patterns of characters) and replace them with a second word (or pattern of characters). Syntax: TRANWRD(source, target, replacement) Here,
Example: |
|
| 9. |
Explain what you mean by SYMGET and SYMPUT. |
|
Answer» In a data STEP, SYMGET returns a macro VARIABLE's value. Conversely, the primary FUNCTION of SYMPUT is to STORE the value of the data set in a macro variable. Syntax of Symput: CALL SYMPUT(macro-variable, value); Syntax of SYMGET: SYMGET(argument) Example: In the following PROGRAM we have created a macro variable and then we have used the symput function to put the value where our key is 'avar' and then we have used the symget function to get the micro variable value. * Create a macro variable. data dataset; set sashelp.class; if _N_ = 1 then do; call symput('avar', name); end; run; %put &avar; * Get macro variable value in a dataset; data needit; var1=symget('avar'); run; |
|
| 10. |
Identify the error in the following code. |
|
Answer» proc MIXED data=SASHELP.IRIS plots=all; MODEL petallength= /; class species; run; Basically, it is a SYNTAX error. In all cases, the MODEL STATEMENT MUST appear after the CLASS statement. |
|
| 11. |
What do you mean by functions and procedures in SAS? |
|
Answer» SAS Procedures: They PROCESS data in SAS data SETS to create statistics, tables, reports, charts, and plots, as well as to perform other analyses and operations on the data. All types of statistical analysis can be performed using SAS procedures. Execution of a procedure is TRIGGERED by the keyword PROC, which starts the step. Here are some SAS PROCs:
SAS Functions: There are many built-in functions in SAS that aid in the analysis and processing of data. You USE them in DATA statements. Different functions take different numbers of ARGUMENTS. Here is a list of SAS functions:
|
|
| 12. |
State the difference between PROC MEANS and PROC SUMMARY. |
|
Answer» Proc SUMMARY and Proc MEANS are essentially the same methods for CALCULATING descriptive statistics, such as mean, count, sum, median, etc. Also, it is capable of calculating several other metrics such as percentiles, quartiles, variances, standard deviations, and t-tests. N, MIN, MAX, MEAN, and STD DEV are the default statistics produced by PROC MEANS.
|
|
| 13. |
Name some SAS system options that are used to debug SAS Micros. |
|
Answer» There are a number of SAS System options that users can USE to troubleshoot macro problems and issues. Macro-option results are automatically shown in the SAS Log.
|
|
| 14. |
Explain how %Let and macro parameters can be used to create micro variables in SAS programming? |
|
Answer» %LET: %Let is GENERALLY used to create MICRO variables and assign values to them. You can define it inside or OUTSIDE a macro. Syntax: %LET macro-variable-name = value; Any number, text or date can be entered in the Value field, depending on what the program requires. How to use the Micro Variable? Whenever referencing macro variables, an AMPERSAND (&) is used followed by the macro variable name as shown below: & <Macro variable Name> Macro Parameters: Macros have variables called parameters whose values you set when you invoke the macro. The parameters are added to a macro by naming them in parenthesis in %macro. Syntax: %MACRO macro-name (parameter-1= , parameter-2= , ......parameter-n = ); Macro Statements; %MEND;How to call a Macro? To call/use micro variables, we use % followed by the macro variable name and then pass parameters. |
|
| 15. |
Write different ways to create micro variables in SAS Programming? |
| Answer» | |
| 16. |
What do you mean by SAS Macros and why to use them? |
|
Answer» Macro is a group of SAS statements (program) that automates repetitive tasks. With SAS's Macros feature, we can avoid repeating SECTIONS of code and use them again and again when needed without having to type them again and it increases readability also. Automation makes your work faster because you don't have to write the same lines of code every day. %MACRO and %MEND are the start and end statements of a macro program. These can be reused multiple times. The SAS program declares them at the beginning and then calls them out during the body of the program when needed. Macro variables contain a VALUE that will be used over and over again by SAS PROGRAMS. With a maximum of 65534 characters, macro variables are one of SAS's most powerful tools. They can be either global or local in scope. The % Local macro variable is a variable that can be defined and accessed inside macro programs only. The %Global macro variable is defined in OPEN code (outside of the macro program) and can be accessed from any SAS program running in the SAS environment. Syntax: The local variables are declared in the following syntax. In the following program, we have created the Macro variable in which we pass the parameters comma-separated and then we have written the Macro statement followed by the %MEND statement. After that, we have called the macro program by passing the parameters. # Creating a Macro program. %MACRO <macro name>(Param1, Param2,....Paramn); Macro Statements; %MEND; # Calling a Macro program. %MacroName (Value1, Value2,.....Valuen); |
|