BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
sascode
Quartz | Level 8
Hi ,
I have a dataset like this:
ItemID sold_Date Bought_Date Indicator_Sold ;
1 . 07/01/2019 0
1 . 08/02/2019 0
1 06/01/2019 06/01/2019 1
1 . 05/01/2019 0
1 . 04/01/2019 0
2 03/31/2019 03/31/2019 1
2 . 02/01/2019 0
........................................................
In this dataset I need to do two tasks:
1.i need to remove these obs for each ItemID with bought_date that is after ItemSold date and keep only these with indicatorsold =1 or indicatorsold =0 and bought date before ItemSold date.
2.After those obs above are removed I need to create an index count, for instance for itemID 1 it will have 1,2 3,
So higher the count it means more back in time.
I appreciate your help.
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

I think this explanation needs to be re-written for clarity. I think your example data set needs to be augmented with examples that meet the criteria you are discussing.

 

i need to remove these obs for each ItemID with bought_date that is after ItemSold date and keep only these with indicatorsold =1 or indicatorsold =0 and bought date before ItemSold date.

 

First, you don't have any examples in the data with bought_date that is after sold_date. Next, your instructions say what to do with bought_date after sold_date, and also what to do if bought_date is before sold_date, but your data has examples where bought_date is equal to sold_date (it's not after and it's not before) and so we don't know what should be done in that case.

--
Paige Miller

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

I think this explanation needs to be re-written for clarity. I think your example data set needs to be augmented with examples that meet the criteria you are discussing.

 

i need to remove these obs for each ItemID with bought_date that is after ItemSold date and keep only these with indicatorsold =1 or indicatorsold =0 and bought date before ItemSold date.

 

First, you don't have any examples in the data with bought_date that is after sold_date. Next, your instructions say what to do with bought_date after sold_date, and also what to do if bought_date is before sold_date, but your data has examples where bought_date is equal to sold_date (it's not after and it's not before) and so we don't know what should be done in that case.

--
Paige Miller
sascode
Quartz | Level 8
I do understand data doesn't make sense with reality, however, I tried to ask for help based on provided variables and rows,
Thank you.
PaigeMiller
Diamond | Level 26

@sascode wrote:
I do understand data doesn't make sense with reality, however, I tried to ask for help based on provided variables and rows,
Thank you.

So does this mean you are not going to re-write the explanation to make it more clear what you want?

--
Paige Miller
sascode
Quartz | Level 8

I was able to solve using another method .
Thank you for you help.
PaigeMiller
Diamond | Level 26

@sascode 

 

People here try to help you, but we assume you will also help us. If you have found another method, show us the solution so we can all benefit.

--
Paige Miller

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 709 views
  • 0 likes
  • 2 in conversation