Quantcast
Channel: Statistics Help @ Talk Stats Forum - SAS
Viewing all articles
Browse latest Browse all 310

Sas Retain first occurrence

$
0
0
Hi,

I'm working with long format data from an educational psychology study.

I have the following setup:


Multiple observations per ID, each with a 'status' variable and a 'date' variable.

For example:


Code:


ID      Status              Date
1      Advanced          2011Jun2
1      Remedial          2011jun12
1      Advanced          2011jul18
1      Remedial          2011july29
2      Advanced          2011may05
2      Advanced          2011may07
2      Advanced          2011may08
3      Remedial          2011apr04
3      Remedial          2011apr09

To give some background, this entire sample of children are considered remedial. We preform some intervention and then follow them up with assessments at different times to see if they can qualify for a switch to advance studies from remedial. This is what the bulk of my data is, those 'assessment's.

What I'm interested in is extracting the first time a student was able to switch from a remedial (assumed to be default) to an advance program. So in essence, I need to extract the first occurrence of status = 'advance' for each student. For those who never switch into advance (that remain remedial) I'd like to just extract the date of their last assessment.


I've tried using the retain statement to no luck. I've been able to transpose the data using proc transpose + arrays to search for the first occurrence of the 'Advance', but I'm not sure how to code the part for students who never get to advance (i.e, pure remedial) because remember I do need their last date of assessment for these kids. For this approach I was using a "do until" loop with the condition do until (status = 'advance'). So for kids who have a switch, it works great. For those that don't, I don't have the date.

I rather work this out using the retain to be honest, however any help is appreciated <3


If anyone can give a hint or tip that might make this easier, please do.

Thanks in advance

Viewing all articles
Browse latest Browse all 310

Trending Articles