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 |
What is the purpose of using the N=PS option?
There is a field containing a date. It needs to be displayed in the format “ddmonyy” if it’s before 1975,”dd mon ccyy” if it’s after 1985, and as ‘disco years’ if its between 1975 and 1985. How would you accomplish this in data step code? Using only PROC FORMAT.
What is slibref?
What is the role of administrative users? : sas-grid-administration
Give e an example of..
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 is the basic structure sas administrator? : Sas-administrator
Are you familiar with special input delimiters? How are they used?
How to get top scorer student from a class-table having different sections A,B, C & D? Each section having same number of students.
How many tiers in sas architecture?
What do the SAS log messages "numeric values have been converted to character" mean?
data study; input Subj : $3. Group : $1. Dose : $4. Weight : $8. Subgroup; x= input(Weight,5.1); datalines; 001 A Low 220 2 002 A High 90 1 003 B Low 193.6 1 004 B High 165 2 005 A Low 123.4 1 ; Why does X get truncated? X shows up as 22 instead of 220,9 instead of 90 and 19.8 instead of 198? This problem doesnt happen with the values 193.6 and 123.4. This does not happen if x is read on the 5. informat instead of the 5.1 informat