Answers for "sas unique id by group"

0

sas unique id by group

proc sort data=sashelp.cars out=cars; 
  by Make DriveTrain Cylinders;
run;

data cars;
  set cars;
  by Make DriveTrain Cylinders;

  if first.Cylinders then grp_id + 1;

  * this answer gives you bonus information ! ;
  if first.Cylinders 
    then seq_in_group = 1; 
    else seq_in_group + 1;
run;
Posted by: Guest on April-28-2022

Browse Popular Code Answers by Language