02-25-2016 04:48 PM
I'm new to this forum and I hope somebody could help me with this problem. I want to check data within an (Person-)ID, check every single line from the first entry to the last and when all checks are done pass to the next Person-ID. I could try it with if first.id or if last.id but then only the first and the last entry are considered what doesn't solve my problem. A simple example is:
|id||record code||start date||end date||reason of diminution||record year|
The result should be (simplified):
if 'end date' is missing then output: first line is accepted
if 'end date' is missing then output: second line is accepted
if 'end date' not missing and 'end date' eq record year than output: third line accepted
and here full stop, the rest of the lines are not accepted anymore, stop the loop within the group and pass to the next person-id.
So, basic problem: how tell SAS to execute a job within a certain id/group and as soon as the job is finished pass to the next one.
I would appreciate your help, thank you.
02-25-2016 04:58 PM
Maybe I'm not getting the objective right. It sounds like you're making an easy problem difficult. Wouldn't this give you the result you are asking for?
if end_date=. or end_date = record_year;
SAS is still processing every record. But the processing deletes the records that you don't want.
Or are you trying for a different result?
02-26-2016 11:01 AM - edited 02-26-2016 11:03 AM
Thank you for your quick response.
You are perfectly right, I didn't see the woods for the trees!
Indeed, I managed today to solve my problem by following your suggestion, I took only those records I need, the others were not taken into consideration so that I have now a solution.
Nevertheless, in a next step I will sitll have to resolve my problem I tried to explain yesterday akwardly. I will have to compare lines withing the same ID, for example if in line 1 the code of diminution is 8 (I will have 10 different codes) then ignore other lines according to certain conditions within the same ID, etc., sort of do conditions within the same ID until the last ID and when coditions finished the quit for the next ID. I am aware that my example is not the best, I will think about it this week-end but at least I managed to solve the first problem.
Thank you very much
02-25-2016 08:31 PM - last edited on 02-26-2016 04:57 AM by RW9
There are many scenarios you didn't clarify .
CODE NOT TESTED.
if n=1 and end_date=. then first=1;
if n=2 and end_date=. then second=1;
if n=3 and end_date=record_year then third=1;
if n le 3 and first and second and third then output;
02-26-2016 11:06 AM
Hello Xia Keshan
Thanks for your answer and suggestion.
Indeed as I explained it to the preceding super user I found the solution with his suggestion but in fact I was looking for a solution a you posted. So what I'm looking for is going into this direction you propose and I will try it this week-end.
Thank you very much