calculate the sum of value using only DATA STEP.
data count_;
input year name $ value;
cards;
2006 xxx 10
2007 yyy 12
2006 xxx 20
2008 yyy 15
2007 xxx 15
;
out put should be like this
year name T_value
-----------------------
2006 xxx 30
2007 xxx 15
2007 yyy 12
2008 xxx 15
Answer Posted / ravi s
it need two steps
step 1 : proc sort; by year name;run;
Step 2: data total (drop = value);
set count_;
by year name;
if first.name then T_value =0 ;
T_value + value;
if last.name then output ;
run;
Note: Hence i am doing work in data step. i need to sort
the data first by using "Proc Sort".
Kindly let me know is the any other method to do?
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
How do you convert basic cube to transaction cube and transaction cube to basic cube?
what techniques and/or procs do you use for tables? : Sas programming
What is the difference between order and group variable in proc report?
what has been your most common programming mistake? : Sas programming
Are you involved in writing the inferential analysis plan? Tables specifications?
what is the difference between unique key and primary key? : Sas-di
What is Linear Regression?
How do you test for missing values?
In ARRAY processing, what does the DIM function do?
Tell e how how dealt with..
What is the purpose of trailing @ and @@? How do you use them?
what is sas enterprise intelligence architecture? : Sas-bi
what are informats in sas? : Sas-administrator
Explain data step in SAS
explain the proc in sas? : Sas-administrator