- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello Team,
Am in the process of running a multivariate model with several continuous longitudinal responses. Am envisaging a wide format data structure with a number of responses, but currently working with two responses (S and D) as follows;
ID | S1 | S2 | S3 | S4 | D1 | D2 | D3 | D4 |
1 | 124 | 125 | 136 | 140 | 77 | 79 | 85 | 90 |
2 | 150 | 145 | 140 | 145 | 82 | 83 | 80 | 82 |
3 | 140 | 135 | 142 | 138 | 80 | 79 | 82 | 78 |
The 'S' and 'D' measurements are taken per individual at four time points (1, 2, 3, 4). The sample data set is from three individuals uniquely identified by 'ID'. Am able to restructure this to a long format as follows;
ID | T | S | D |
1 | 1 | 124 | 77 |
1 | 2 | 125 | 79 |
1 | 3 | 136 | 85 |
1 | 4 | 140 | 90 |
2 | 1 | 150 | 82 |
2 | 2 | 145 | 83 |
2 | 3 | 140 | 80 |
2 | 4 | 145 | 82 |
3 | 1 | 140 | 80 |
3 | 2 | 135 | 79 |
3 | 3 | 142 | 82 |
3 | 4 | 138 | 78 |
I now wish to combine the two sequences into one sequence (SDcomb) by a stack up procedure such that the resulting data set will appear as follows;
ID | T | SDcomb |
1 | 1 | 124 |
1 | 1 | 77 |
1 | 2 | 125 |
1 | 2 | 79 |
1 | 3 | 136 |
1 | 3 | 85 |
1 | 4 | 140 |
1 | 4 | 90 |
2 | 1 | 150 |
2 | 1 | 82 |
2 | 2 | 145 |
2 | 2 | 83 |
2 | 3 | 140 |
2 | 3 | 80 |
2 | 4 | 145 |
2 | 4 | 82 |
3 | 1 | 140 |
3 | 1 | 80 |
3 | 2 | 135 |
3 | 2 | 79 |
3 | 3 | 142 |
3 | 3 | 82 |
3 | 4 | 138 |
3 | 4 | 78 |
How do I achieve this? Thank you.
Kind Regards,
MoZes
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Rick,
Thank you so much for helping me out. Have been cracking my head all day, finally sorted. Thanks Bro!
Regrads,
MoZes
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data have;
input ID T S D;
datalines;
1 1 124 77
1 2 125 79
1 3 136 85
1 4 140 90
2 1 150 82
2 2 145 83
2 3 140 80
2 4 145 82
3 1 140 80
3 2 135 79
3 3 142 82
3 4 138 78
;
data want;
set have;
SDComb = S; output;
SDComb = D; output;
drop S D;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Rick,
Thank you so much for helping me out. Have been cracking my head all day, finally sorted. Thanks Bro!
Regrads,
MoZes