BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SheilaSR
Obsidian | Level 7

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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

2 REPLIES 2
ballardw
Super User

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.

 

SheilaSR
Obsidian | Level 7

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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