BookmarkSubscribeRSS Feed
alexanthonymaj0
Calcite | Level 5

Hi Everyone,

I am looking to create a new variable that counts unique customers, based on the month - represented by Custer_ID and Report_Month respectively. Any help would be greatly appreciated! 

Here is what I have so far - thanks in advance

 

data sales_summary1;
         set Sales_Details;
         Distinct_Customer = count(Customer_Id,Report_Month);
        keep Distinct_Customer report_month sales_channel;
run;

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

Like this?

proc sql;
  select Report_Month, count(unique Custer_ID) as Count
  from Sales_Details
  group by Report_Month;
quit;

 

 

alexanthonymaj0
Calcite | Level 5

Yes, thank you so much for your reply, I am really appreciative! I have a couple of follow-up questions, if you don't mind.

First off, I am trying to group the variables (1) Count_Customer (2) Count_Sales_Rep (3) Sales_Volume based on

(1) the Channel 'Sales_Channel' and (2) the Month 'Report_Month'  -- I know the results I am getting are not correct (I have attached to this post). How would I go about achieving this?

 

 

 

 

 

proc sql;
       create table work.sales_summary1 AS
select report_month, count(unique Customer_ID) as Count_Customer, count(unique Sales_Rep_ID) as Count_Sales_Rep, Sales_Volume, Sales_Channel
         from sales_details
group by Report_Month and Sales_Channel;

quit;

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