Hello Guys
i thnk its little tricky.. i have a dataset like this segment, iD and group. i want a macro that loops though each segments and picks 6 rows(2 rows from group w , 3 rows from b,1 rows from m) this 6 parameter should be dynamic parameters, in future if i need to change it 5 or 7 or whaterver obs from each group i can easily change so please note this. and for next run again 6 rows if the groups id exhausted pick from other group to make it 6 rows and so on..and this is for multiple runs..i hope i explined the requirement if not do not hesitate to comment. Thanks
Segement
ID
group
1
101
w
1
102
w
1
103
w
1
105
b
1
106
b
1
107
b
1
108
b
1
109
b
1
110
b
1
111
m
1
112
m
3
115
w
1
116
w
3
117
b
3
118
b
3
119
m
output for only Segment 1:
1st run 6 records
2nd run 6 records
3rd run 6 records
4th run records
from W 2 IDs
101
from W remianing 1 IDs
103
102
101
102
from B 3 remaining 3 IDs
108
103
102
from B 3 IDs
105
109
105
108
106
110
106
109
107
from m remianing 1 ID
112
107
110
from m 1 IDs
111
from w to q to make 6
101
111
112
sample output for Segment 3:
1st run 6 records
2nd run
2 from w
115
116
116
117
2 from b
117
118
118
119
1 from m
119
115
1 from w
115
116
... View more