- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.:)
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I tested out the code and it got error, that shows variable is not found
data merged;
run;
proc rank data=merged out =quartiles groups=4;
VAR totalprice
Ranks price_quartile;
run;
proc print data=merged;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You want Q3 for each and every customer or want Q3 for all of customer. Does variable NUMUNITS stand for a freq/weight variable ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
numunits is just another column but i supposed is not needed for my question.
i want Q3 for all customer.