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!!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 523 views
  • 0 likes
  • 2 in conversation