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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.