how to add distinctly var variable values ex..
Data a;
input var;
datalines;
0
1
2
3
-1
-2
-3
;
run;
adding all +ve value in one varibale n do the same for -ve
too
Answer Posted / ashish
data a;
input num;
cards;
1
2
3
-5
-7
-8
9
10
0
-56
-3
;
run;
data b ;
retain sum_n sum_p;
set a end=last;
if _n_=1 then sum_n = 0;
if _n_=1 then sum_p = 0;
if(num<0) then sum_n= sum(sum_n,num);
else sum_p= sum(sum_p,num);
if last then output;
run;
Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
How can I remove header from output data set?
explain the proc in sas? : Sas-administrator
what is sas enterprise intelligence architecture? : Sas-bi
what is the effect of the options statement errors=1? : Sas programming
what is null hypothesis? why do you consider that?
Do you need to know if there are any missing values?
it will become easy if uuu provide website linkssss and list of consultanciessssss
Define run-group processing?
What is your favorite all time computer book? Why?
What does proc print, and proc contents are used for?
What is PDV?
what is the difference between calculating the 'mean' using the mean function and proc means? : Sas programming
Name few SAS functions?
how do you debug and test your sas programs? : Sas programming
what is the use of sas management console? : Sas-di