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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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