Hello,
I have a dataset which is a crossbat between age group (in row, 16 categories) and municipality (in line, 79 categories):
1 | 2 | 3 | 4 | … | 16 | |
1 | 245 | 285 | 335 | 340 | 320 | 290 |
2 | 250 | 255 | 305 | 300 | 240 | 320 |
3 | 1470 | 1560 | 2020 | 1600 | 1255 | 1570 |
4 | 520 | 535 | 580 | 475 | 375 | 365 |
5 | 1190 | 1125 | 1280 | 1040 | 770 | 1065 |
… | ||||||
79 | 1395 | 1695 | 2130 | 2150 | 1870 | 1265 |
I would like to transpose it in a data set of 3 rows and 79*16 lines:
Municipality | Age Group | Population |
1 | 1 | 245 |
1 | 2 | 285 |
,, | ,, | … |
1 | 79 | 290 |
,,, | ,,, | … |
79 | 14 | 1687 |
79 | 15 | 1543 |
79 | 16 | 1265 |
I'm sure it's easy, but I just don't know how.
Transpose using either data step or proc transpose:
SAS Learning Module: How to reshape data wide to long using proc transpose
SAS Learning Module: Reshaping wide to long using a data step
Transpose using either data step or proc transpose:
SAS Learning Module: How to reshape data wide to long using proc transpose
SAS Learning Module: Reshaping wide to long using a data step
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.