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
what is SAS OPTIMIZATION?
How substr function works in sas?
Describe the function and untility of the most difficult SAS macro that you have written.
What are the 3 components in sas programming?
Do you need to rearrange the order of the data for the report?
what is the difference between: x=a+b+c+d; and x=sum (of a, b, c ,d);? : Sas programming
Give some examples where proc report’s defaults are different than proc print’s defaults?
Mention what is the difference between nodupkey and nodup options?
What is the difference between class statement and by statement in proc means?
: and & modifiers.
WHAT IS SAS WEB SERVICE and what are the steps to create an xml service ?
How do you debug and test your SAS programs?
what is sas application server, database server, sas olap server and sas metadata server? : Sas-di
How would you identify a macro variable?
hi all, I need the SAS DI DUMP(A00 260) for attending the certification. if any one have, pls provide it.Please Email to vrpotluri@hotmail.com. Thanks - Ramana