Hi,
I have following data i need count of first three obs in fourth obs with var as tot and count of next three(5,6,7) in obs 8 as var tot
eg:
obs var cnt
1 eg 3
2 eg 4
3 eg 5
4 tot 12
5 rt 3
6 rt 4
7 rt 1
8 tot 8
I'm guessing this is what you want..
data have;
input var $ cnt;
datalines;
eg 3
eg 4
eg 5
rt 3
rt 4
rt 1
;
data want(drop=s);
do _n_=1 by 1 until (last.var);
set have;
by var notsorted;
s+cnt;
output;
end;
var='tot';cnt=s;
output;
s=0;
run;
Is this for reporting purposes or do you want a new data set like this?
Hi,
i want data set like these
Thanks
I'm guessing this is what you want..
data have;
input var $ cnt;
datalines;
eg 3
eg 4
eg 5
rt 3
rt 4
rt 1
;
data want(drop=s);
do _n_=1 by 1 until (last.var);
set have;
by var notsorted;
s+cnt;
output;
end;
var='tot';cnt=s;
output;
s=0;
run;
Thank you
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: