Hi,
My data consists of individuals (ID) who can appear several times with the same Date (Datex) but in different years.
The Year variable is unique within its ID and Datex. In my example, ID=1 has two different Datex that appear 4 times each.
The variable Year as unique values in each Block of variable Datex (see the table below). What I need to do is reformat the "Mark_type"
from long to wide for each ID within the DATEx
Tanks!
ID | Datex | Year | Mark_type |
1 | 2005-05-05 | 2008 | 2 |
1 | 2005-05-05 | 2010 | 1 |
1 | 2005-05-05 | 2011 | 1 |
1 | 2005-05-05 | 2016 | 1 |
1 | 2012-02-02 | 2013 | 2 |
1 | 2012-02-02 | 2015 | 1 |
1 | 2012-02-02 | 2016 | 1 |
1 | 2012-02-02 | 2018 | 1 |
2 | 2010-05-16 | 2011 | 3 |
2 | 2011-07-05 | 2011 | 3 |
Why re-format at all? What can you do with a wide format that you can't do with a long format?
@MCB2 wrote:
I need later on to concatinate the variable I am reshaping.
This doesn't really explain why you need it. This doesn't really explain how having a wide data set lets you do things that you can't do with a long data set. What are you going to do (what analysis, what report) with this concatenated variable(s) once you have them?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.