BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
darkmoon178
Calcite | Level 5

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'

IdValue
Hcompany1
Q1
Q2
Q3
Hcompany2
Q2
Q4
Q6
Hcompany3
Q10
Q12
Q14

 

And here is the result that I want:

IdValuecompany
Hcompany1company1
Q1company1
Q2company1
Q3company1
Hcompany2company2
Q2company2
Q4company2
Q6company2
Hcompany3company3
Q10company3
Q12company3
Q14company3

 

Any suggestions for my problem?

Thank you for reading. Have a good day!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Use a RETAINed variable.

data want;
  set have;
  if id='H' then company=value;
  retain company;
run;

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

Use a RETAINed variable.

data want;
  set have;
  if id='H' then company=value;
  retain company;
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 585 views
  • 1 like
  • 2 in conversation