Hello everyone ! (sorry for my english) The tittle of the topic is not so explicit because i don't know how to tell that.. I'm putting here an example and then I explain you what i'm expecting for : Data have ;
format id1 id2 $5. periode 2. cpt2 8. sum_cum 8.;
input id1 id2 periode cpt2 sum_cum ;
cards;
10000 00001 0 20 20
10000 00001 1 13 33
10000 00001 2 17 50
10000 00001 3 50 100
10000 00001 4 10 110
10000 00001 5 15 125
10000 00001 6 81 81
20000 00002 0 5 5
20000 00002 1 3 8
20000 00002 2 10 18
20000 00002 3 1 19
20000 00002 4 11 30
20000 00002 5 30 60
;
run ; This is the table : - id1 is a head office - id2 is an agency - periode : 0 is the last month of the first trimester (01/03/2019 --> 31/03/2019) periode : 1 is the month before (01/02/2019 --> 30/02/2019) periode : 3 is the month before (01/01/2019 --> 31/01/2019) ... - cpt2 is the number of survey respondents per periode - sum_cum is the number cumulated of cpt2 I'm trying to select data depending on 2 conditions : I want to know which period i have to take acording to 3 criteria : - I need minimum 3 periods (so minimum periode 0, 1 and 2) - I want minimum 20 respondents - The maximum of periode is 36, If i don't have 20 respondents on the three periods, then i want to look for the next period and see if I have 20 respondents, if it is less than 20 again, see the next period, .... if i don't have 20 respondents in 36 periodes then delete, good bye, we don't care haha So this is what i would like to have on the output : Data want ;
format id1 id2 $5. periode 2. cpt2 8. sum_cum 8.;
input id1 id2 periode cpt2 sum_cum ;
cards;
10000 00001 0 20 20
10000 00001 1 13 33
10000 00001 2 17 50
20000 00002 0 5 5
20000 00002 1 3 8
20000 00002 2 10 18
20000 00002 3 1 19
20000 00002 4 11 30
;
run ; I don't know how write it in SAS, I don't think that it is very difficul but if you can help me, i will be very grateful !! Thank you ! Onizuka
... View more