
Two ways to assign incremental value by group Count Number of Variables assigned in a macro variablesĢ2.
#Common sas interview questions how to#
How to make SAS stop macro processing on ErrorĬheck out this link - Stop SAS Macro on ErrorĢ1. In PROC SORT, NODUPKEY option is used to remove duplicates based on a variable. How to use NODUPKEY kind of operation with PROC SQL The RANUNI function is used to generate random numbers. The RANUNI and OUTOBS functions can be used for selecting N random samples. The EXCEPT operator returns rows from the first query that are not part of the second query.ġ8. However, the value of i is now 4 and not 3, the last value before it would be greater than 3 as the stop value.ġ7. At the beginning of the fourth iteration, the value of count is 4, which is found to be greater than the stop value of 3 so the loop stops.

It is because when the first time the loop processes, the value of count is 1 the second time, 2 and the third time, 3.
#Common sas interview questions code#
What would be the value of i after the code below completes It is when the %SYSEVALF function comes into picture.ġ6. %let last = %eval (4.5+3.2) returns error as %EVAL cannot perform arithmetic calculations with operands that have the floating point values. Difference between %EVAL and %SYSEVALF functionsīoth %EVAL and %SYSEVALF are used to perform mathematical and logical operation with macro variables. MLOGIC option will display how the macro variable resolved each time in the LOG file as TRUE or FALSE for %IF %THEN.ġ5. How to debug %IF %THEN statements in a macro code Use double quotes to reference a macro variable in a selection criteria. How to reference a macro variable in selection criteria You need to find out manager name against each employee ID.ġ3. It comprises of employees' name, ID and manager ID.

Select count(*) into: nrows from sashelp.class ħ. Two ways to create a macro variable that counts the number of observations in a dataset Quit Tutorial : Learn PROC SQL with 20 ExamplesĦ. Where score in (select max(score) from example5 where score not in (select max(score) from example5)) Select the Second Highest Score with PROC SQL Please note that WHERE Option can be used for subsetting on a newly created variable. WHERE statement would return an error "newly derived variable is not on file". Only IF statement can be used for subsetting when it is based on a newly derived variable. Can both WHERE and IF statements be used for subsetting on a newly derived variable?
