Hi sasusers, i need to merge the 2 datasets as some columns not included in the dataset. Therefore, is it possible if i use proc univariate and then merge together? And i tried using sql but do not get the result.
Just an example of the dataset:
Spending data set, there are spendingid, customerid, totalprice and numunits
Spending_id Customer_id totalprice numunits
1212112 100000 19 2
989898 112121 298 10
3i31030 20000 2 22
Customer dataset, there are customerid and firstname
Customer_id firstname
12311111 Ellen
9908009 JOhn
3376247 Jay
Question: Show all the customers in the 3rd quartile of their spending. Display their name, total spent and their customer id
Thanks in advance.:)
I didn't provide merge code, I left that as an exercise for you - it's your homework after all, and you seemed to have this step from previous questions.
You first need to summarize your table 1 to a single record per customer ID.
Then merge in names from table 2.
Then use PROC RANK to find quartiles.
Good luck
Do you need to summarize your data first? Do you have more than one record for each customer in Table 1?
Otjeriwse make the final table you want using a join, containing the name and totalprice.
Then use PROC RANK with group = 4. It will divide the data into quartiles, 0-3. Take rank = 2
Proc RANK data=merged out=quartiles groups=4;
VAR totalprice;
Ranks price_quartile;
run;
Then filter the quartiles data set to obtain the desired quartile.
I didn't provide merge code, I left that as an exercise for you - it's your homework after all, and you seemed to have this step from previous questions.
You first need to summarize your table 1 to a single record per customer ID.
Then merge in names from table 2.
Then use PROC RANK to find quartiles.
Good luck
You want Q3 for each and every customer or want Q3 for all of customer. Does variable NUMUNITS stand for a freq/weight variable ?
numunits is just another column but i supposed is not needed for my question.
i want Q3 for all customer.
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!
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.