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


 

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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