Desktop productivity for business analysts and programmers

how to add a fix number to data (with positive and negative values) without getting affected by sign

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 87
Accepted Solution

how to add a fix number to data (with positive and negative values) without getting affected by sign

Can someone please help in adding 60 to each row in the following data:

 

 

data have;
  infile cards truncover expandtabs;
  input X;
cards;
248
182
115
48
-19
-84
-146
-205
-258
-307
349
384
-413
-436
452
462
-468
-469
-467
-463
;
run;

 

So that the output looks like this:

 

XX_new
248308
182242
115175
48108
-19-79
-84-144
-146-206
-205-265
-258-318
-307-367
349409
384444
-413-473
-436-496
452512
462522
-468-528
-469-529
-467-527
-463-523

Accepted Solutions
Solution
‎11-25-2016 12:11 PM
Respected Advisor
Posts: 3,156

Re: how to add a fix number to data (with positive and negative values) without getting affected by

data have;
  infile cards truncover expandtabs;
  input X ;
  X_plus_60=(abs(x)+60)*(x/abs(x));
cards;
248
182
115
48
-19
-84
-146
-205
-258
-307
349
384
-413
-436
452
462
-468
-469
-467
-463
;
run;

View solution in original post


All Replies
Solution
‎11-25-2016 12:11 PM
Respected Advisor
Posts: 3,156

Re: how to add a fix number to data (with positive and negative values) without getting affected by

data have;
  infile cards truncover expandtabs;
  input X ;
  X_plus_60=(abs(x)+60)*(x/abs(x));
cards;
248
182
115
48
-19
-84
-146
-205
-258
-307
349
384
-413
-436
452
462
-468
-469
-467
-463
;
run;

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 199 views
  • 0 likes
  • 2 in conversation