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. 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. 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. The EXCEPT operator returns rows from the first query that are not part of the second query.ġ8. The RANUNI and OUTOBS functions can be used for selecting N random samples. How to use NODUPKEY kind of operation with PROC SQL The RANUNI function is used to generate random numbers. In PROC SORT, NODUPKEY option is used to remove duplicates based on a variable. How to make SAS stop macro processing on ErrorĬheck out this link - Stop SAS Macro on ErrorĢ1. Two ways to assign incremental value by group Count Number of Variables assigned in a macro variablesĢ2. Write a macro to split data into N number of datasets %GLOBAL is used to create a global macro variable and would remain accessible till the end of a session. Suppose you are asked to write a macro to split large data into 2 parts (not static 2). In the macro, user should have flexibility to change the number of datasets to be created.ģ1.