Hi everyone,
I'm trying to work with this dataset:
The original data having companies stack on top of each other, and it can only be separated if Id= 'H'
| Id | Value |
| H | company1 |
| Q | 1 |
| Q | 2 |
| Q | 3 |
| H | company2 |
| Q | 2 |
| Q | 4 |
| Q | 6 |
| H | company3 |
| Q | 10 |
| Q | 12 |
| Q | 14 |
And here is the result that I want:
| Id | Value | company |
| H | company1 | company1 |
| Q | 1 | company1 |
| Q | 2 | company1 |
| Q | 3 | company1 |
| H | company2 | company2 |
| Q | 2 | company2 |
| Q | 4 | company2 |
| Q | 6 | company2 |
| H | company3 | company3 |
| Q | 10 | company3 |
| Q | 12 | company3 |
| Q | 14 | company3 |
Any suggestions for my problem?
Thank you for reading. Have a good day!
Use a RETAINed variable.
data want;
set have;
if id='H' then company=value;
retain company;
run;
Use a RETAINed variable.
data want;
set have;
if id='H' then company=value;
retain company;
run;
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 save with the early bird rate—just $795!
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.