Hello,
I am stuck on how to proceed on the below. My original data looks like this:
| aa | bb |
| 1 | 10 |
| 11 | 15 |
| 16 | 25 |
I would like to transform the above data to something like the below:
| aa | bb | newvar |
| 1 | 10 | 1 |
| 1 | 10 | 2 |
| 1 | 10 | 3 |
| 1 | 10 | 4 |
| 1 | 10 | 5 |
| 1 | 10 | 6 |
| 1 | 10 | 7 |
| 1 | 10 | 8 |
| 1 | 10 | 9 |
| 1 | 10 | 10 |
| 11 | 15 | 11 |
| 11 | 15 | 12 |
| 11 | 15 | 13 |
| 11 | 15 | 14 |
| 11 | 15 | 15 |
| 16 | 25 | 16 |
| 16 | 25 | 17 |
| 16 | 25 | 18 |
| 16 | 25 | 19 |
| 16 | 25 | 20 |
| 16 | 25 | 21 |
| 16 | 25 | 22 |
| 16 | 25 | 23 |
| 16 | 25 | 24 |
| 16 | 25 | 25 |
Any advice would be highly appreciated..
Regards,
Tina
data have;
input aa bb;
cards;
1 10
11 15
16 25
;
data want;
set have;
do newvar=aa to bb;
output;
end;
run;
data have;
input aa bb;
cards;
1 10
11 15
16 25
;
data want;
set have;
do newvar=aa to bb;
output;
end;
run;
Thank you so much! This worked wonders!
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.