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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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