BookmarkSubscribeRSS Feed
Decay2020
Fluorite | Level 6

Hi all,

I have below table. I want to adjust my recovery column as per ID against any non-zero amount1.

 

data have;

infile cards delimeter= "," ;

input ID$ amount1 recovery;

cards;

a,10,0

a,20,0

a,30,40

b,0,0

b,10,5

b,20,40

; run;

 

data WANT:

IDamount1recoveryfinal
A10010
A20010
A30400
B000
B1050
B20400

 

Thanks!

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

I don't understand this. Can you explain the exact logic behind the new variable?

Decay2020
Fluorite | Level 6
I need to deduct recovery from amount1. if recovery is more than amount 1 then the remaining balance needs to be deducted from previous non-zero amount1 till the recovery balance is completely set off against amount1.
PeterClemmensen
Tourmaline | Level 20

If recovery > amount1 then you want to subtract recovery from amount1? That still does not make sense to me. Why not just set the new var to zero when this is fulfilled?

 

Please be very specific about the logic.

Decay2020
Fluorite | Level 6
Apologies for any confusion. let me give you an example of "A".
now when we deduct 30-40, the remaining 10 recovery should get deducted from previous non-zero amount1, that is 20-10 = 10

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 976 views
  • 0 likes
  • 2 in conversation