Write and run SAS programs in your web browser

Is there a way to efficiently identify and input missing data for repeated measures data?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 12
Accepted Solution

Is there a way to efficiently identify and input missing data for repeated measures data?

[ Edited ]

Hi, I am a student using SAS studio to analyze a set of repeated measures data.  The beginning of my dataset looks like this:

subject trt sex age visit time visual
1 Active F 71 1 0 59
1 Active F 71 2 4 55
1 Active F 71 3 12 45
2 Active F 59 1 0 65
2 Active F 59 2 4 70
2 Active F 59 3 12 65
2 Active F 59 4 24 65
2 Active F 59 5 52 55
3 Placebo F 73 1 0 40
3 Placebo F 73 2 4 40
3 Placebo F 73 3 12 37
3 Placebo F 73 4 24 17

 

In this dataset, "visual" is the outcome measure/response variable. Each subject had the opportunity to have the variable "visual" evaluated 5 times-i.e. at visits 1-5. However, not all subjects made it to all 5 visits. For example, as labeled in red above, subject 1 only had 3 visits, and subject 3 had 4 visits. Subject 2 had all 5.

 

I would like to enter missing data lines for the missing data. For example:

3 Placebo F 73 5 52 .     to indicate that this data is missing.

 I would like to do a nonlinear mixed models analysis of this repeated measures data using proc mixed or proc nlmixed.

 

My questions are:

1. Is there an efficient way in SAS to identify which subjects do not have all 5 visits and then enter the missing data?

2. If data is missing, do I need to enter it into the dataset as I'm describing? Or can I do my analysis without adding these missing rows? I have the impression from the attached SAS guide pages 5-8, that maybe I don't need to add in the missing data lines if I specify the repeated statement appropriately.

 

I was planning to use the answer from this question: https://communities.sas.com/t5/SAS-Procedures/Adding-extra-data-to-existing-dataset/td-p/117310 to add my missing data lines (or just to enter them in manually), but I was wondering if there is a better way to identify which subjects are missing visit data, rather than going through the 1101 observations in the dataset manually.

 

Thank you in advance for your help!

Sheila

 


Accepted Solutions
Solution
‎05-23-2017 01:33 PM
Super User
Posts: 10,857

Re: Is there a way to efficiently identify and input missing data for repeated measures data?

Assuming your data is grouped by subject and sorted by visit as shown this should create the additional records you requested.

 

data want;
   set have;
   by subject notsorted;
   array x (5) _temporary_ (0, 4, 12, 24,52);
   output;
   if last.subject and visit ne 5 then do;
      call missing(visual);
      do visit=(visit+1) to 5;
         time= x[visit];
         output;
      end;
   end;
end;

Assumes that your time and visit are actually numeric.

 

View solution in original post


All Replies
Solution
‎05-23-2017 01:33 PM
Super User
Posts: 10,857

Re: Is there a way to efficiently identify and input missing data for repeated measures data?

Assuming your data is grouped by subject and sorted by visit as shown this should create the additional records you requested.

 

data want;
   set have;
   by subject notsorted;
   array x (5) _temporary_ (0, 4, 12, 24,52);
   output;
   if last.subject and visit ne 5 then do;
      call missing(visual);
      do visit=(visit+1) to 5;
         time= x[visit];
         output;
      end;
   end;
end;

Assumes that your time and visit are actually numeric.

 

Occasional Contributor
Posts: 12

Re: Is there a way to efficiently identify and input missing data for repeated measures data?

Thank you for your help ballardw! I really appreciate your help! The code worked great and makes sense. Thank you!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 149 views
  • 0 likes
  • 2 in conversation