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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: