BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Jhonarsalina
Calcite | Level 5

Good Morning,

I request your kind cooperation.

I have the following table:

 

IDVehicleClassBrandModel
112132AutomovileFord2000
112135AutomovileChevrolet2020
212138AutomovileAudi2015
212141MotocycleBMW2010
212144BusFord1950
312147BusChevrolet2008

 

I need to have it as follows:

IDVehicle_1Class_1Brand_1Model_1Vehicle_2Class_2Brand_2Model_2Vehicle_3Class_3Brand_3Model_3
112132AutomovileFord200012135AutomovileChevrolet2020    
212138AutomovileAudi201512141MotorcycleBMW201012144BusFord1950
312147BusChevrolet2008        

 

the data is as follows:

data datos;
input ID $ Vehicle $ Class $ Brand $Model;
datalines;
1 12132 Automovile Ford 2000
1 12135 Automovile Chevrolet 2020
2 12138 Automovile Audi 2015
2 12141 Motocycle BMW 2010
2 12144 Bus Ford 1950
3 12147 Bus Chevrolet 2008
;
run;

 

Beforehand thank you very much.

 

Greetings

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

There are exact examples of this in the transposing data tutorials below:
Long to Wide:
https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/

https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/



@Jhonarsalina wrote:

Good Morning,

I request your kind cooperation.

I have the following table:

 

ID Vehicle Class Brand Model
1 12132 Automovile Ford 2000
1 12135 Automovile Chevrolet 2020
2 12138 Automovile Audi 2015
2 12141 Motocycle BMW 2010
2 12144 Bus Ford 1950
3 12147 Bus Chevrolet 2008

 

I need to have it as follows:

ID Vehicle_1 Class_1 Brand_1 Model_1 Vehicle_2 Class_2 Brand_2 Model_2 Vehicle_3 Class_3 Brand_3 Model_3
1 12132 Automovile Ford 2000 12135 Automovile Chevrolet 2020        
2 12138 Automovile Audi 2015 12141 Motorcycle BMW 2010 12144 Bus Ford 1950
3 12147 Bus Chevrolet 2008                

 

the data is as follows:

data datos;
input ID $ Vehicle $ Class $ Brand $Model;
datalines;
1 12132 Automovile Ford 2000
1 12135 Automovile Chevrolet 2020
2 12138 Automovile Audi 2015
2 12141 Motocycle BMW 2010
2 12144 Bus Ford 1950
3 12147 Bus Chevrolet 2008
;
run;

 

Beforehand thank you very much.

 

Greetings

 

 


 

View solution in original post

3 REPLIES 3
ballardw
Super User

Please describe what you can/will do with the proposed layout that you can't with the existing table structure.

 

Your proposed structure is extremely hard to work with for most purposes.

 

Reeza
Super User

There are exact examples of this in the transposing data tutorials below:
Long to Wide:
https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/

https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/



@Jhonarsalina wrote:

Good Morning,

I request your kind cooperation.

I have the following table:

 

ID Vehicle Class Brand Model
1 12132 Automovile Ford 2000
1 12135 Automovile Chevrolet 2020
2 12138 Automovile Audi 2015
2 12141 Motocycle BMW 2010
2 12144 Bus Ford 1950
3 12147 Bus Chevrolet 2008

 

I need to have it as follows:

ID Vehicle_1 Class_1 Brand_1 Model_1 Vehicle_2 Class_2 Brand_2 Model_2 Vehicle_3 Class_3 Brand_3 Model_3
1 12132 Automovile Ford 2000 12135 Automovile Chevrolet 2020        
2 12138 Automovile Audi 2015 12141 Motorcycle BMW 2010 12144 Bus Ford 1950
3 12147 Bus Chevrolet 2008                

 

the data is as follows:

data datos;
input ID $ Vehicle $ Class $ Brand $Model;
datalines;
1 12132 Automovile Ford 2000
1 12135 Automovile Chevrolet 2020
2 12138 Automovile Audi 2015
2 12141 Motocycle BMW 2010
2 12144 Bus Ford 1950
3 12147 Bus Chevrolet 2008
;
run;

 

Beforehand thank you very much.

 

Greetings

 

 


 

Jhonarsalina
Calcite | Level 5

@Reeza wrote:

There are exact examples of this in the transposing data tutorials below:
Long to Wide:
https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/

https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/



@Jhonarsalina wrote:

Good Morning,

I request your kind cooperation.

I have the following table:

 

IDVehicleClassBrandModel
112132AutomovileFord2000
112135AutomovileChevrolet2020
212138AutomovileAudi2015
212141MotocycleBMW2010
212144BusFord1950
312147BusChevrolet2008

 

I need to have it as follows:

IDVehicle_1Class_1Brand_1Model_1Vehicle_2Class_2Brand_2Model_2Vehicle_3Class_3Brand_3Model_3
112132AutomovileFord200012135AutomovileChevrolet2020    
212138AutomovileAudi201512141MotorcycleBMW201012144BusFord1950
312147BusChevrolet2008        

 

the data is as follows:

data datos;
input ID $ Vehicle $ Class $ Brand $Model;
datalines;
1 12132 Automovile Ford 2000
1 12135 Automovile Chevrolet 2020
2 12138 Automovile Audi 2015
2 12141 Motocycle BMW 2010
2 12144 Bus Ford 1950
3 12147 Bus Chevrolet 2008
;
run;

 

Beforehand thank you very much.

 

Greetings

 

 


Thanks a lot


 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 707 views
  • 0 likes
  • 3 in conversation