Solved
Contributor
Posts: 24

# Repeated values

A hypothetical study would like to determine what percentage of their participants are currently in-care and what percentage are currently virally suppressed.  You have a hypothetical dataset that contains repeated laboratory results for each client (i.e. multiple rows of data per client).  Variables include:  client_id, test_date, test_type, test_result.  Please describe how you would calculate the desired percentages. Please include specific functions (coding) that you would use in SAS to complete the analysis.

Accepted Solutions
Solution
‎04-16-2017 07:30 PM
PROC Star
Posts: 8,163

## Re: Repeated values

1. Use proc sort to put the data in the order of Patient and, within patient, descending date order.

2. Use either proc sort with nodupkey on Patient, of a datastep, outputting only the first (most recent) record for each patient

3. Run a proc freq to get the counts and percentages

Art, CEO, AnalystFinder.com

All Replies
PROC Star
Posts: 8,163

## Re: Repeated values

You have: client_id, test_date, test_type, test_result

What, in those variables, defines that someone is currently in-care andvirally suppressed?

Art, CEO, AnalystFinder.com

Contributor
Posts: 24

## Re: Repeated values

test_result determine that someone is currently in-care or virally suppressed.

test_result = positive = currently in-care

test_result = negative = virally suppressed

PROC Star
Posts: 8,163

## Re: Repeated values

Can they only be one, the other or neither of the two?

Art, CEO, AnalystFinder.com

p.s. You'll get more informative info if you provide two data steps, one that shows example data, and the other that shows the file you'd like to create based on your example data.

Contributor
Posts: 24

## Re: Repeated values

Because there are repeated lab values the study participants can be either virally suppressed or currently in-care depending on the latest lab value i.e. test_date

Contributor
Posts: 24

A hypothetical study would like to determine what percentage of their participants are currently in-care and what percentage are currently virally suppressed.  You have a hypothetical dataset that contains repeated laboratory results for each client (i.e. multiple rows of data per client).  Variables include:  client_id, test_date, test_type, test_result.  Please describe how you would calculate the desired percentages. Please include specific functions (coding) that you would use in SAS to complete the analysis.

PROC Star
Posts: 8,163

Art, CEO, AnalystFinder.com

Solution
‎04-16-2017 07:30 PM
PROC Star
Posts: 8,163

## Re: Repeated values

1. Use proc sort to put the data in the order of Patient and, within patient, descending date order.

2. Use either proc sort with nodupkey on Patient, of a datastep, outputting only the first (most recent) record for each patient

3. Run a proc freq to get the counts and percentages

Art, CEO, AnalystFinder.com

Contributor
Posts: 24

## Re: Repeated values

Thank you so much for your help!

☑ This topic is solved.