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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.