BookmarkSubscribeRSS Feed
Zeremiel
Calcite | Level 5

Hi, im really new to SAS and i have to develope something that is crushing me hard. 

I have a Dataset that looks like this:

id               amount                   paytype                  expire_date

 

001                -15,2                        1                              17/12/2008

001                -30,1                        1                                     .

001                 30,1                        2                              15/03/2019

001                -8,3                          1                                     .

001                 8,3                          2                               13/02/2020

002                 -8,3                         1                                     .

002                 -7,3                         1                                15/12/2019 

Other things:                             

The paytype 1 is always a negative amount value, paytype 2 is always positive.
Some of the expire_date values of the paytype 1 are missing


Wath i need to do:
I need to give to those missing values the value of a paytype 2 with same absolute amount and id.

 

But here comes the trick

A paytype 2 can only be used to copy its expire_date value only once.

So in this case 

001                -15,2                          1                              17/12/2008

001                -30,1                          1                                     .

001                 30,1                          2                              15/03/2019

001                -30,1                          1                                     .

001                 30,1                          2                               13/02/2020

I need to give to the first missing value the value of the first paytype 2 and to the second missing value the second paytype 2 value. 

Im totally blind and pretty new to SAS so any help wold be greatly appreciated. Thank you.

 



 

1 REPLY 1
ChrisNZ
Tourmaline | Level 20

Please provide the data as a program (data step or sql inserts).

Also please provide the desired output.

Is the value you might want to use to replace the missing value always located just after the missing value?

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1 reply
  • 526 views
  • 0 likes
  • 2 in conversation