DATA Step, Macro, Functions and more

Repeated values

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

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: 7,474

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

 

View solution in original post


All Replies
PROC Star
Posts: 7,474

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

Occasional Contributor
Posts: 17

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: 7,474

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.

 

Occasional Contributor
Posts: 17

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

Occasional Contributor
Posts: 17

Please help

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: 7,474

Re: Please help

I think I already answered this in the thread at: https://communities.sas.com/t5/Base-SAS-Programming/Repeated-values/m-p/350399#M81439

 

Art, CEO, AnalystFinder.com

Solution
‎04-16-2017 07:30 PM
PROC Star
Posts: 7,474

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

 

Occasional Contributor
Posts: 17

Re: Repeated values

Thank you so much for your help!

☑ This topic is solved.

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

Discussion stats
  • 8 replies
  • 249 views
  • 0 likes
  • 2 in conversation