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.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.