BookmarkSubscribeRSS Feed
Mdormond
Calcite | Level 5

I have a sample data set (see attached) in which identification numbers of study participants as well as dates of visits appear along with diagnoses (DX). I need to calculate number of diagnoses per year of the study. Each identification number occurs more than once and each visit date (event date) has more than one diagnosis (DX1-DX4). I need to drop the diagnoses that are irrelevant and then somehow find the earliest date of repeat diagnoses. In sample data set the diagnosis of interest is "560" and occurs on visit date -22 for the first time. Exposure "870" is also of interest and occurs on day -133. Is there any way to tag each visit date to each IDC-9 code at a diagnosis and then determine which diagnosis occurred first? Dates are measured in days from January 1st 1999. Ideally I would like to collapse each identification number into one single line of observation with the first date of the outcome of interest as well as the exposure of interest as variables "date_exposure" "date_outcome" "exposure" "outcome".  Additionally, a subject may have more than one outcome or exposure of interest and thus both would need to be retained. I then would like to run a simple frequency procedure to get frequency of outcomes and exposures by year. When making the date variables on the year of occurrence is important and thus I would like them to appear as "1999", "2000", etc. Is there any easy way to code this to achieve the desired outcome?

IDEvent DateDX1DX2DX3DX4
33-133910870--
33-22560780865-
3344560---
33171450456870-
33890---
1 REPLY 1
Reeza
Super User

What do you want the outcome to look like?

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 725 views
  • 0 likes
  • 2 in conversation