BookmarkSubscribeRSS Feed
Ovaty
Fluorite | Level 6

Hi everybody!

 

I need your help to solve my issue.

I need to do a merge/transpose column and leave some columns fixed.

 

Ex.:

CarStateCityPart1Part2Part3Part4
BMWMIDetroit1234
BMWMIDetroit5678
BMWMIDetroit9101112
JaguarUTSLC20212223
JaguarUTSLC24252627
JaguarUTSLC28293031

 

I need this exit below for BMW:

CarStateCityPart
BMWMIDetroit1
BMWMIDetroit2
BMWMIDetroit3
BMWMIDetroit4
BMWMIDetroit5
BMWMIDetroit6
BMWMIDetroit7
BMWMIDetroit8
BMWMIDetroit9
BMWMIDetroit10
BMWMIDetroit11
BMWMIDetroit12

 

Thanks a lot!!!

Gustavo.

2 REPLIES 2
Astounding
PROC Star

This should do it:

 

data want;
   set have;
   array parts {4} part1-part4;
   do k=1 to 4;
      part = parts{k};
      output;
   end;
   drop k part1-part4;
run;
Ovaty
Fluorite | Level 6

Yes, its great!!

 

Thanks a lot!!

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 440 views
  • 0 likes
  • 2 in conversation