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 / arun kumar

proc sql;
create table arun as
select sum(case when var>=0 then var else . end) as num_p,
sum(case when var<0 then var else . end) as num_n
from a;
quit;

proc print;
run;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you use the do loop if you don’t know how many times you should execute the do loop?

743


describe the interaction table in sas di? : Sas-di

581


how sas deals with business intelligence? : Sas-bi

576


how would you determine the number of missing or nonmissing values in computations? : Sas programming

648


I have a dataset concat having a variable a b & c. How to rename a b to e & f?

750






Difference between nodup and nodupkey options?

627


Tell me more about the parameters in macro? : sas-macro

582


What does the RUN statement do?

845


How to limit decimal places for the variable using proc means?

587


What is the use of PROC gplot?

629


What do the sas log messages “numeric values have been converted to character” mean? What are the implications?

708


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?

1764


what is change analysis in sas di ? : Sas-di

599


if a variable contain dates like "2015/01"---"2015/12" (yymm) ,How to add day to those dates,if them month is jan then 31 if the month is feb then 28 so on ...

932


what are the types of interactive display types? : Sas-bi

644