BookmarkSubscribeRSS Feed
jonatan_velarde
Lapis Lazuli | Level 10

Good day my friends:

 

I'm begining to work with dates, and i can't solve this simple problem:

 

This store has the record of payment of its workers like this:

 

Worker Date
1 09/20/1998
2 09/26/1998
3 09/27/1998
1 10/20/1998
2 10/26/1998
3 10/27/1998
1 11/21/1998
2 11/26/1998
3 11/27/1998
1 12/21/1998
2 12/27/1998
3 12/28/1998
1 01/22/1999
3 01/28/1999
3 02/28/1999
3 03/28/1999
3 04/28/1999
3 05/28/1999
3 06/28/1999
3 07/28/1999
3 08/28/1999

 

So, what is needed is: first group by workers, into workers is needed order the dats from older to newer, and add a colum indicating the number of payment, manually could be done and obtain this:

 

Order Worker Date
1 1 09/20/1998
2 1 10/20/1998
3 1 11/21/1998
4 1 12/21/1998
5 1 01/22/1999
1 2 09/26/1998
2 2 10/26/1998
3 2 11/26/1998
4 2 12/27/1998
1 3 09/27/1998
2 3 10/27/1998
3 3 11/27/1998
4 3 12/28/1998
5 3 01/28/1999
6 3 02/28/1999
7 3 03/28/1999
8 3 04/28/1999
9 3 05/28/1999
10 3 06/28/1999
11 3 07/28/1999
12 3 08/28/1999

 

how can i do to make this using SAS??

 

Thank you very much

 

1 REPLY 1
varunk
Calcite | Level 5

You can try the below code

 

Proc SQL;
Select Sum (Worker) as Order, Worker, Date from Table1
Group by Worker, date
Order by Worker, date;
Quit;

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 754 views
  • 0 likes
  • 2 in conversation