BookmarkSubscribeRSS Feed
biglerc
Obsidian | Level 7

Hi everyone,

 

I have been struggling with this for a couple days, so hope somebody out there has done this before. 

 

I have a dataset that is currently vertical, and I want to transpose it to be horizontal.  That's no problem with PROC TRANSPOSE.  The tricky part is that after the data is transposed, I need to assign labels to the new variables from a field that existed in the initial data.  

 

Currently I have something like this:

variable_name       field_label

INV                         Physician

INST                       Institution

 

I have transposed the dataset to this:

INV      INST

Dr Joe  Hospital1

Dr Jane Hospital2

 

What I am not sure how to do is assign the values from field_label to the INV and INST variables after the transpose.    I have 397 rows in the intial dataset, and it can change in the future, so I really want to be able to do this dynamically.

 

Any suggestions? 

 

Thanks!

2 REPLIES 2
Reeza
Super User

IDLABEL option in PROC TRANSPOSE.

 

proc transpose data=.....;
...
idlabel field_label;
...
run;

@biglerc wrote:

Hi everyone,

 

I have been struggling with this for a couple days, so hope somebody out there has done this before. 

 

I have a dataset that is currently vertical, and I want to transpose it to be horizontal.  That's no problem with PROC TRANSPOSE.  The tricky part is that after the data is transposed, I need to assign labels to the new variables from a field that existed in the initial data.  

 

Currently I have something like this:

variable_name       field_label

INV                         Physician

INST                       Institution

 

I have transposed the dataset to this:

INV      INST

Dr Joe  Hospital1

Dr Jane Hospital2

 

What I am not sure how to do is assign the values from field_label to the INV and INST variables after the transpose.    I have 397 rows in the intial dataset, and it can change in the future, so I really want to be able to do this dynamically.

 

Any suggestions? 

 

Thanks!


 

biglerc
Obsidian | Level 7
Thank you so much, Reeza! Sorry for my delay in replying!

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
  • 2 replies
  • 1000 views
  • 2 likes
  • 2 in conversation