hi ,
im unable to convert month to quarter
data Customers;
input Cust_id Month Spend;
cards;
1 JAN 100
1 FEB 200
1 MAR 300
1 APR
2 JAN 400
2 FEB 100
2 MAR 600
3 JUN 100
;run;
data CUSTOMER_SEGMENTAION;
input CUST_id Segment;
cards;
1 HIGH
2 MOD
3 LOW
4 HIGH
5 MOD
6 LOW
;run;
i want output like
QUARTER | SEGMENT | COUNT_CUST | TOTAL_SPEND |
Q1 | HIGH |
|
|
Q1 | MOD |
|
|
Q1 | LOW |
|
|
Q2 | HIGH |
|
|
Q2 | MOD |
|
|
Q3 | LOW |
|
|
…… | ………… | ………… | ……….. |
QUARTER WISE (QUARTER LIKE ( (JAN FEB MAR ) for Q1 and same for q2 and q3
SEGEMENT WISE DISTINCT COUNT OF CUSTOMER AND THERE TOTAL SPEND.
if in month it would been a no then it was possible but here month are in character .
So should i use sum case with it???
Create a value format that converts Jan,Feb,Mar to Q1 (and so on), and use that in a SQL group by, or create a new variable with it, which you can use in by group processing in proc summary etc.
Use formats to convert your text string months to quarters.
Merge the two data sets.
Use PROC SUMMARY to produce the sums and count of customers.
Also ... hint, hint, hint ... you would be wise to not use text strings such as JAN for months, you make your life simpler if you use numbers for months, 1 is January, 2 is February, and so on, and then converting to quarters is even easier. This advice applies to all calendar data, use either actual numbers, of SAS date values or SAS date/time values, do not use text strings to represent calendar values.
thanks for the reply ,
was able to solve using if else
easy problem it was
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.