Prev: Reading a directory and selecting only desired filenames
Next: Scatterplot matrix from ODS in PROC CORR
From: Friends on 26 Mar 2010 03:34 Hey All, I have a dataset named test the snapshot of which is included below. I have to divide this table in to smaller tables in such a way that the total length of the name field in a table does not exceed 50 characters Obs name id len a 1 damodaranpilla 23 14 14 2 panickerettan 34 13 27 3 shivashankaran 32 14 41 4 karunakaranpilla 989 16 57 5 muralidharan 36 12 69 6 keshavannambiar 76 15 84 7 mohanlal 1 8 92 8 sreekumaranthampi 54 17 109 9 ravivarmathamburan 56 18 127 10 pishardy 88 8 135 11 velayudhan 344 10 145 12 aniyankutty 76 11 156 13 beeranikka 333 10 166 14 ahmedkutty 656 10 176 15 pappachan 647 9 185 16 chackochan 646 10 195 17 musiliyar 554 9 204 If you look at the above example,we need to sum up the length of variable named "NAME" and if the sum is less than 50 make a separate table out of it.For example in the above case the sum of length of "NAME" for first three observations comes out to be 41 and if we add the length of name for the next observation that is the 4 th observation we exceed a length boundary of 50.So we will make a table using the first 3 observation.Now in the second run if we add the length of "NAME" for 4,5,6 observation it comes out to be 43 now if we add the 7 observation the sum turns out to be 51 so the table should have only observations 4,5,6.This process has to repeat till we reach the end of the table.Hope you guys got the problem. A further extension to this provlem would be that in addition to considering only NAME variable there will other variable which need to be considered like ZIP,PHONE NUMBER. Sachin.
From: Richard A. DeVenezia on 26 Mar 2010 11:00
On Mar 26, 3:34 am, Friends <sachin.s.n...(a)gmail.com> wrote: > Hey All, > > I have a dataset named test the snapshot of which is included below. > I have to divide this table in to smaller tables in such a way that > the total length of the name field in a table does not exceed 50 > characters > > Obs name id len a > > 1 damodaranpilla 23 14 14 > 2 panickerettan 34 13 27 > 3 shivashankaran 32 14 41 > 4 karunakaranpilla 989 16 57 > 5 muralidharan 36 12 69 > 6 keshavannambiar 76 15 84 > 7 mohanlal 1 8 92 > 8 sreekumaranthampi 54 17 109 > 9 ravivarmathamburan 56 18 127 > 10 pishardy 88 8 135 > 11 velayudhan 344 10 145 > 12 aniyankutty 76 11 156 > 13 beeranikka 333 10 166 > 14 ahmedkutty 656 10 176 > 15 pappachan 647 9 185 > 16 chackochan 646 10 195 > 17 musiliyar 554 9 204 > > If you look at the above example,we need to sum up the length of > variable named "NAME" and if the sum is less than 50 make a separate > table out of it.For example in the above case the sum of length of > "NAME" for first three > observations comes out to be 41 and if we add the length of name for > the next observation that is the 4 th observation we exceed a length > boundary of 50.So we will make a table using the first 3 > observation.Now in the second run if we add the length of "NAME" for > 4,5,6 observation it comes out to be 43 now if we add the 7 > observation the sum turns out to be 51 so the table should have only > observations 4,5,6.This process has to repeat till we reach the end of > the table.Hope you guys got the problem. > > A further extension to this provlem would be that in addition to > considering only NAME variable there will other variable which need to > be considered like ZIP,PHONE NUMBER. > > Sachin. Certainly possible, but highly discouraged. Dynamic splitting is often performed using HASH object OUTPUT method. One row look ahead of a variable is sometimes accomplished using MERGE without a BY. MERGE have have(firstosb=2 keep=X rename=(X=nextX)); Q: In what analytic or organizational scheme would such a breaking up scheme make sense ? Q: What are the output table names supposed to be ? If it's homework, your professor is a nitwit. -- Richard A. DeVenezia http://www.devenezia.com |