I have input data like this:
CLIENT_ID | PRD | R1 | R2 | TR1 | TR2 |
112 | A | 1 | 0 | 1 | 0 |
112 | B | 0.5 | 0 | 0.8 | 0 |
I want to create bucket out of this data by creating a separate variable called Metric. The dataset should look like this:
CLIENT_ID | PRD | METRIC | BUCKET1 | BUCKET2 |
112 | A | R | 1 | 0 |
112 | A | TR | 1 | 0 |
112 | B | R | 0.5 | 0 |
112 | B | TR | 0.8 | 0 |
Thanks
Chandan Mishra
It looks like you need:
data want;
set have;
length metric $ 2;
METRIC = 'R';
BUCKET1 = R1;
BUCKET2 = R2;
output;
METRIC = 'TR';
BUCKET1 = TR1;
BUCKET2 = TR2;
output;
keep CLIENT_ID PRD METRIC BUCKET1 BUCKET2;
run;
It looks like you need:
data want;
set have;
length metric $ 2;
METRIC = 'R';
BUCKET1 = R1;
BUCKET2 = R2;
output;
METRIC = 'TR';
BUCKET1 = TR1;
BUCKET2 = TR2;
output;
keep CLIENT_ID PRD METRIC BUCKET1 BUCKET2;
run;
@AstoundingThanks for such an easy solution.
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.