Hello mates;
I am new to SAS and I am stuck on my next step of data manipulation. I am not providing any code because I have no crew where to begin from with this logic.
I have data as shown below. I am interested in only keeping rows when the makes the initial unique change from the previous position. For example staff one first made the first ever change on 02jan2001 (from being cleaner to administrator). For staff 2, the first change ever was on 02jan2019 from Manager to Deputy_Director). For staff who have no change in position (for example staff 3), I would like to just retain the first row.
Data I have;
staff | Start_date | End_date | Job position |
1 | 01jan2000 | 01jan2001 | cleaner |
1 | 02jan2001 | 01jan2002 | administrator |
1 | 02jan2002 | 01jan2003 | Deputy_manager |
1 | 02jan2004 | 01jan2005 | Manager |
2 | 01jan2000 | 02jan2004 | Manager |
2 | 03jan2004 | 03jan2006 | Manager |
2 | 02jan2006 | 01jan2009 | Deputy_Director |
2 | 02jan2009 | 01jan2012 | Director |
2 | 01jan2012 | 01jan2014 | Unemployed |
2 | 02jan2014 | 01jan2016 | Director |
3 | 01jan2000 | 06jan2000 | unemployed |
3 | 07jan2000 | 01jul2000 | Unemployed |
4 | 01jan2000 | 01jun2000 | Cleaner |
4 | 02jun2000 | 01aug2000 | Manager |
5 | 02aug2006 | 01jan2019 | Director |
Data I want;
Patient | Start_date | End_date | Job position |
1 | 02jan2001 | 01jan2002 | administrator |
2 | 02jan2006 | 01jan2009 | Deputy_Director |
3 | 01jan2000 | 02jan2000 | unemployed |
4 | 01jan2000 | 01jan2000 | Manager |
Thank you.
Dathan Byonanebye
Hello mates;
I am new to SAS and I am stuck on my next step of data manipulation. I am not providing any code because I have no crew where to begin from with this logic.
I have data as shown below. I am interested in only keeping rows when the makes the initial unique change from the previous position. For example staff one first made the first ever change on 02jan2001 (from being cleaner to administrator). For staff 2, the first change ever was on 02jan2019 from Manager to Deputy_Director). For staff who have no change in position (for example staff 3), I would like to just retain the first row.
Data I have;
staff | Start_date | End_date | Job_position |
1 | 01jan2000 | 01jan2001 | cleaner |
1 | 02jan2001 | 01jan2002 | administrator |
1 | 02jan2002 | 01jan2003 | Deputy_manager |
1 | 02jan2004 | 01jan2005 | Manager |
2 | 01jan2000 | 02jan2004 | Manager |
2 | 03jan2004 | 03jan2006 | Manager |
2 | 02jan2006 | 01jan2009 | Deputy_Director |
2 | 02jan2009 | 01jan2012 | Director |
2 | 01jan2012 | 01jan2014 | Unemployed |
2 | 02jan2014 | 01jan2016 | Director |
3 | 01jan2000 | 06jan2000 | unemployed |
3 | 07jan2000 | 01jul2000 | Unemployed |
4 | 01jan2000 | 01jun2000 | Cleaner |
4 | 02jun2000 | 01aug2000 | Manager |
5 | 02aug2006 | 01jan2019 | Director |
Data I want;
Patient | Start_date | End_date | Job_position |
1 | 02jan2001 | 01jan2002 | administrator |
2 | 02jan2006 | 01jan2009 | Deputy_Director |
3 | 01jan2000 | 02jan2000 | unemployed |
4 | 01jan2000 | 01jan2000 | Manager |
Thank you.
Dathan Byonanebye
@DathanMD Please don't double post questions.
Why is Staff=5 not included? She has no change in position, though only 1 obs?
Hi @DathanMD
In addition to @PeterClemmensen 's question, how would like you manage the case of staff=3?
3 |
01jan2000 |
06jan2000 |
unemployed |
3 |
07jan2000 |
01jul2000 |
Unemployed |
- option 1: retrieve the first row (-> this is what you described in your initial post)
- option 2: collapse dates so that the end date appears as 01jul2000. In this case how would you manage time interruptions?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.