BookmarkSubscribeRSS Feed
MUKASADAVID
Calcite | Level 5

 

Hello Community,

I want to create a variable containing the days each person was followed up in the study using one date as the reference start date/study commencement date. There is a variable in my data set which has dates on which the participants were examined first and dates for the follow up examinations. The variable which has the dates on which measurements were taken has dates entered in format like this "20050101" which represents the year=2005, month=january and day=1st day of the month.
The data has five years of follow up but each person entered the study at different dates and different numbers of hospital visits.

I want to create a variable having number of days each person was followed up and for each visit.

 

data finished;
input id Date diagnosis @;
datalines;
1 20050101  0
1 20050502  0
1 20070708  0
1 20090306  0
2 20070608  0
2 20090502  1
2 20090805  1
2 20090703  1
2 20100507  0
3 20050101  0
3 20050502  0
3 20070708  0
3 20090306  0
3 20070608  0
4 20060502  1
4 20090205  0
4 20090403  1
4 20100907  0

 

how can i create a time variable in days for these repeated measurements? 

 

I have tried different codes but they dont give the correct days followed up which I need for conducting a survival analysis.

will be glad to be assisted.

1 REPLY 1
art297
Opal | Level 21

Convert your dates into SAS dates. That way you can subtract any two dates to get the number of days elapsed. e.g.:

data want;
  set finished;
  date=input(put(date,8.),yymmdd8.);
  format date date9.;
run;

Art, CEO, AnalystFinder.com

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!

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