Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Handling Missing Longitudinal Data
00:00
5 left

Handling Missing Longitudinal Data

HardSQL · PostgreSQL

Problem

How do you handle missing or erroneous data points in a longitudinal research study?

For this SQL exercise, treat a missing point as a scheduled visit without a measurement. Treat a point as erroneous when its value is NULL, outside the range 0 to 100, or recorded before the scheduled visit.

Output

  1. Return one row per missing or erroneous scheduled visit.
  2. Include participant_id, participant_name, scheduled_visit_id, scheduled_date, issue_type, observed_value, and recorded_at.
  3. Sort by participant, scheduled date, and scheduled visit ID.

Schema

participants
ColumnTypeDescription
participant_idPKINTUnique study participant identifier
participant_nameVARCHAR(100)Participant display name
scheduled_visits
ColumnTypeDescription
scheduled_visit_idPKINTUnique scheduled visit identifier
participant_idINTParticipant expected at the visit
scheduled_dateDATEDate on which the measurement was expected
measurements
ColumnTypeDescription
measurement_idPKINTUnique measurement identifier
scheduled_visit_idINTScheduled visit associated with the measurement
measurement_valueNUMERIC(6,2)Observed study value expected to be between 0 and 100
recorded_atTIMESTAMPTimestamp when the measurement was recorded
Tablesparticipantsscheduled_visitsmeasurements
Interviewer

Your question is Handling Missing Longitudinal Data. Start with the requirements and the three tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.