You might also try:
Proc sort data=sample;
by idnum;
run;
proc print data=sample;
by idnum;
ID IDNUM;
var LastName;
run;
which will create a somewhat different appearance for the by group output than a simple by statement. The BY variable then appears as a row spanning value in the first column of the output for each BY value instead of having the "BYVAR=Value" appear before a table. Which can significantly reduce the number of vertical lines in the output, especially with 2 or more by variables.
ID behaves differently in many of the procedures that have the option so it is worth investigating when offered as an option. For instance it is possible to get the value of a variable associated with the 3 largest values of another in Proc Means/ Summary using ID plus some additional code.