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
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.