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 / rpd
I can give logic part, rest kindly manage :)
step 1:proc sort the dataset by "PID YEAR"
step2 :in the datastep "SET" it using by PID YEAR
create a temp variable say _SUM and RETAIN _SUM,
reset _SUM=0 on FIRST.YEAR.
T_VALUE=_SUM+VALUE
I guess this will work
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Why and when do you use proc sql?
Mention what are the data types does SAS contain?
Are you involved in writing the inferential analysis plan? Tables specfications?
How does SAS handle missing values in: assignment statements, functions, a merge, an update, sort order, formats, PROCs?
Differentiate between ceil and floor functions.
how do you debug and test your sas programs? : Sas programming
What is the difference between INPUT and INFILE ?
what are validation tools that are used in sas? : Sas-administrator
what is a method for assigning first.var and last.var to the by groupvariable on unsorted data? : Sas programming
What are the different operating system platforms in which we can use sas? : sas-grid-administration
data data1; input dt account; format dt date9.; cards; 1745 1230 1756 1120 1788 1130 1767 1240 ; data data2; input startdt enddt total; format startdt date9. enddt date9.; cards; 1657 1834 12300 1557 1758 16800 1789 1789 12300 1788 1345 12383 1899 1899 13250 ; proc sql; create table data3 as select * from data1 as x left join data2 as y on x.dt>=y.startdt and x.dt<=y.enddt; quit; Here, we are getting cartision product. But,I want left join report consisting of this program. It should not get duplicate values. you can modify the program also.
explain the use of % includes a statement in sas? : Sas-administrator
What does the trace option do?
What are the applications primarily used by business analyst? : Sas-bi
Do you need to know if there are any missing values?