Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Explain the use of proc gplot? : sas-grid-administration

929


Explain the difference between using drop = data set option in set and data statement?

1102


what is sas business intelligence? : Sas-bi

1092


How does proc sql work?

1026


What is run-group processing?

1090


What do the SAS log messages "numeric values have been converted to character" mean?

1327


What is the difference between order and group variable in proc report?

1365


Explain how merging helps to combine data sets.

992


How do you connect the desktop application to metadata server? : sas-grid-administration

1029


what is the primary data source for the wrs? : Sas-bi

1135


Mention what is the difference between nodupkey and nodup options?

954


How would you define the end of a macro? : sas-macro

1034


what is study design in while working with SAS? what are screening variables in SAS?

2179


In sas admin differentiate between roles and capabilities? : sas-grid-administration

939


How to read an input file in sas?

1093