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?

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