BookmarkSubscribeRSS Feed
tbanh
Fluorite | Level 6

Hello, I have searched for the answer to my problem but to no avail. I have a longitudinal dataset that looks like this:

 

Screen Shot 2019-06-17 at 9.05.31 AM.png

 

Each subject currently has five repeated measures (at time points 0-4). I would like to take the variable on the left ("recall_trial6") and append it the variable on the right ("recall"), in essence, adding a repeated measure. At the same time, I would need to add another time point to "trial" so that it runs from 0-5. Any help or tips are greatly appreciated!

3 REPLIES 3
Reeza
Super User
Given the expected input above, please show the expected output.
tbanh
Fluorite | Level 6

Subject       Trial           Recall

1                      0                   9

1                      1                 14

1                      2                 19

1                      3                 21

1                      4                 20

1                      5                 23

2                      0                   4

2                      1                   7

2                      2                  11

2                      3                  13

2                      4                  16

2                      5                  12

...                     ...                 ...

 

Reeza
Super User
data want;
set have;

by id;
output;

if last.id then do;
   trial = 5;
   recall=recall_trial6;
    output;
end;

*keep id trial recall;

run;

 

This should work then. 


@tbanh wrote:

Hello, I have searched for the answer to my problem but to no avail. I have a longitudinal dataset that looks like this:

 

Screen Shot 2019-06-17 at 9.05.31 AM.png

 

Each subject currently has five repeated measures (at time points 0-4). I would like to take the variable on the left ("recall_trial6") and append it the variable on the right ("recall"), in essence, adding a repeated measure. At the same time, I would need to add another time point to "trial" so that it runs from 0-5. Any help or tips are greatly appreciated!


 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1318 views
  • 0 likes
  • 2 in conversation