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
Answers were Sorted based on User's Feedback
Answer / karthik
data a;
input var;
cards;
0
1
2
3
-1
-2
-3
;
data report;
set a;
if var>=0 then var1=var;
else var2=var;
drop var;
run;
/*Report output*/
proc print data=report;
run;
Is This Answer Correct ? | 4 Yes | 1 No |
Answer / ravikumar marappan
data test;
input var;
retain sub;
retain ad;
if var < 0 then sub=sum(sub,var);
else ad=sum(ad,var);
datalines;
1
2
3
-1
-2
-3
;
run;
Is This Answer Correct ? | 4 Yes | 2 No |
Answer / 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 |
Answer / 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 |
Answer / mahesh babu b
data test1;
set a;
if find(var,'-') >0 then b=var;
else c=var;
run;
Is This Answer Correct ? | 3 Yes | 5 No |
how we can call macros with in data step?
What is auto call macro and how to create a auto call macro? What is the use of it? How to use it in sas with macros? : sas-macro
what are the three main credit bureau names
1 Answers Synchrony Financial,
What are the rows present in protocol Violation table?
2 Answers Accenture, Quintiles,
Identify statements whose placement in the DATA step is critical?
In sas, what are the areas that you are most interested in? : sas-grid-administration
sas implimented companies in hyderabad
what is SAS/Graph?
You have a data set of 100 observations,how can you restrict the output so that the output has only data from row no. 10 to row no. 20
What is the difference between the proc sql and data step?
What are the best sas programming practices for handling very large datasets? : sas-grid-administration
WHAT DOES A SAS SPECIFICATION DOCUMENT SDS CONTAIN ?