Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

In SAS proc sql, incrementing can be done using the following ways:

  1. Using the "INTO" clause to increment a variable value:
proc sql;
    select max(id)+1 into :new_id from my_table;
quit;
  1. Using the "CALCULATED" keyword to increment a computed column value:
proc sql;
    select id, calculated id+1 as new_id
    from my_table;
quit;
  1. Using the "DATA" step to create a new variable and assign it an incremented value:
data my_table;
    set my_table;
    new_id = id + 1;
run;

Note: The above examples assume the variable being incremented is called "id".