Home > Software engineering >  How do I split up each variable into separate groups in SAS/SQL?
How do I split up each variable into separate groups in SAS/SQL?

Time:05-26

At the moment, I have this data set.

Date
01/01/2010
01/02/2010
01/03/2010
01/04/2010
01/05/2010
...

I would like to split each date up into different categories. I would want to end up with


Date               New
01/01/2010         1
01/01/2010         2
01/01/2010         3
01/02/2010         1
01/02/2010         2
01/02/2010         3
...

This seems pretty simple, but I have never actually run across this before. Thank you.

CodePudding user response:

Not something you can do with SQL.

But trivial to do in SAS as long are the observations are ordered by the grouping variable.

data want;
  set have;
  by date;
  new   1;
  if first.date then new=1;
run;
 
  • Related