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
@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.
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
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.