05-29-2014 03:00 AM
I am trying to produce a report with a range diplay of multiple volumes.
Any insight or suggestion of which PROC to use is appreciated.
05-29-2014 04:27 AM
What is the criterion to be a range in your example, for instance why is d4 not used and yet result includes d4 (to make 16)?
Once you identify your groups then assign a new variable e.g;
attrib range format=$20.;
if 1 <= input(tranwrd(d_var,"d",""),best.) <= 4 then range="d1-d4";
if 5 <= input(tranwrd(d_var,"d",""),best.) <= 8 then range="d5-d5";
However there are other ways depending on the data used and the required outcome, so please provide examples.
05-29-2014 05:58 AM
My range is not fixed and varies, there will be 10000+ lines and cannot find range for each. So a generic range assignment would be a good idea. I do not know how to do it.
Here is my data:
05-29-2014 08:51 AM
From what I can see, you will need two steps, first to separate the serial numbers and form groups, next to summarize and concatenate.
infile cards ;
input var :$ amt;
group+(var_d-lag(var_d) ne 1);
summ+(-summ*(lag(group) ne group))+amt;
retain var_range 'dddddddd';
if first.group then var_range=var;
if last.group then do;
keep var_range summ;
05-29-2014 09:56 AM
There is no PROC that has the ability to read your mind. You have to decide the method to form groups. Do you want to take every 4 observations and collapse them into one group? Do you want to sum the amounts until they reach a certain level to define a group? Do you want 10 groups, using a relatively even split of the original observations? Just what are you thinking is the definition of a group?
05-29-2014 10:07 AM
Thanks Hai.Kuo for you code, i will try and let you know if i am successful.
Astounding, Basically my requirement is to group all the variables continiue together, if there is a gap in observation then needs to form a next group.