Add Sequential ID for Observations in SAS
Posted on Jun 20, 2015 in Computer Science
Things under legendu.net/outdated are outdated technologies that the author does not plan to update any more. Please look for better alternatives.
** Things under legendu.net/outdated are outdated technologies that the author does not plan to update any more. Please look for better alternatives. **
data s1; set s; obs_id = n; run;
proc sql; create table s1 as select monotonic() as obs_id, * from s ; run;
- The
monotonicfunction runs beforesortandgroup by. So even if it gives distinct observation ID, it guarantees no specific order of observations. It is suggested that you use the data step approach rather than thenonotonicway in SQL if you want the generated observation IDs to preserve some kind of order of observations.