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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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