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 program data vector? : Sas-administrator
What do you know about symput and symget?
Which command is used to perform sorting in sas program?
what is factor analysis? : Sas-administrator
Is the physical structure of the data set in the same orientation as the report? Do you need to reshape the data sets? What method should you use to reshape the data–DATA steps,PROC TRANSPOSE,output data set from a procedure?
What are the data types in sas?
What Proc glm does?
I have a dataset concat having variable a b & c. How to rename a b to e & f?
what are input dataset and output dataset options? : Sas programming
How does proc sql work?
What are the data types that sas contain?
Explain the difference between using drop = data set option in set and data statement?
What is SAS? What are the functions does it performs?
please can you tell me that in companies sas work are doing by through sas coding or sas wizard ??
Mention common programming errors committed in sas ?