Tuesday, December 14, 2010

Producing a Row Number using Proc SQL

This is an undocumented feature of SAS, where in we can achieve a feature similiar to the _N_ of the Data step using the Proc SQL

PROC SQL;
SELECT MONOTONIC() AS Row_Number FORMAT=COMMA6.,
ITEM,
UNITS,
UNITCOST FROM PURCHASES;
QUIT;

/* 2.3.4.11 Code Example: Producing a Row Number with the NUMBER Option */
PROC SQL NUMBER;
SELECT ITEM,
UNITS,
UNITCOST
FROM PURCHASES;
QUIT;

No comments:

Post a Comment