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
Explain the use of proc gplot? : sas-grid-administration
Explain the difference between using drop = data set option in set and data statement?
what is sas business intelligence? : Sas-bi
How does proc sql work?
What is run-group processing?
What do the SAS log messages "numeric values have been converted to character" mean?
What is the difference between order and group variable in proc report?
Explain how merging helps to combine data sets.
How do you connect the desktop application to metadata server? : sas-grid-administration
what is the primary data source for the wrs? : Sas-bi
Mention what is the difference between nodupkey and nodup options?
How would you define the end of a macro? : sas-macro
what is study design in while working with SAS? what are screening variables in SAS?
In sas admin differentiate between roles and capabilities? : sas-grid-administration
How to read an input file in sas?