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
What are the ways in which macro variables can be created in sas programming?
If you were told to create many records from one record, show how you would do this using array and with proc transpose?
Mention what is SAS data set?
What are types of transport files?
Explain the difference between nodup and nodupkey options?
do you need to know if there are any missing values? : Sas programming
Hello Friends, am new to this forum and am not good at sas progarmming. please can any one of you send me couple of sample large sample SAS Jobs which can you use 200 MB of data and other sas job upto 25GB of data. am doing a performance testing on our legacy systems and new upgraded system. I would really appreciate if you can do me this favor Thank you Priya
How sas treats the dsd delimiters?
Can you execute a macro within a macro? Describe. : sas-macro
How will you use the WHO Drug Dictionary for Reporting Clinical Trials?
Name and describe few sas character functions that are used for data cleaning in brief.
If a variable contains only numbers, can it be a character data type?
what is program data vector? : Sas-administrator
What are pdv and it functions?
Which are the statements whose placement in the data step is critical?