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
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
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.
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
@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:
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
Thanks a lot
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!
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.
Ready to level-up your skills? Choose your own adventure.