BookmarkSubscribeRSS Feed
willd9
Calcite | Level 5

I'm trying to filter my dataset to show customers who have bought more than one product from my company. 

 

The dataset I'm working with has a column called 'customer_first_order' which has a 1 or 0 to indicate yes or no, respectively. This is fine because I can filter to see where customers have a 0 in this column. The only issue is I want to show the repeating customer's first order as well which will obviously show as 1 under 'customer_first_order'. The customers have a unique ID called customer_id. Any ideas on how to tackle this?

 

Thanks in advance

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

@willd9 Hi and welcome to the SAS Community 🙂

 

A problem like this is so much easier to help you with if you provide us with some sample of your data and what you want the desired result to look like. Makes it much easier to provide usable code.

Reeza
Super User

Welcome to the SAS community forums. 

 

You likely want to use BY group processing to add another flag. 

Documentation on BY group processing can be found here, with some annotated images showing how it works. 

 

If you need further assistance beyond this please post some example data show what you have and what you need as a result. Ideally you'd also show what you tried. If you cannot provide real data, please make fake data and/or use SASHELP.CLASS or CARS to illustrate your issue. These data sets are available to all SAS programmers.

 

Here are instructions on how to provide sample data as a data step:
https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

 


@willd9 wrote:

I'm trying to filter my dataset to show customers who have bought more than one product from my company. 

 

The dataset I'm working with has a column called 'customer_first_order' which has a 1 or 0 to indicate yes or no, respectively. This is fine because I can filter to see where customers have a 0 in this column. The only issue is I want to show the repeating customer's first order as well which will obviously show as 1 under 'customer_first_order'. The customers have a unique ID called customer_id. Any ideas on how to tackle this?

 

Thanks in advance


 

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

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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