BookmarkSubscribeRSS Feed
raja777pharma
Fluorite | Level 6

HI,

 

Thank you very much for help.

I have try te get some sammple data here and expalined rules and output.

Plese help me code with differently previosu code

 

data ce;
input usubjid :$40 ceterm :$200 cestdtc :yymmdd10.;
format cestdtc yymmdd10.;
datalines;
D169CC00001/E0201004    CV DEATH    14-09-21
D169CC00001/E0201004    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    04-02-20
D169CC00001/E0201004    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    03-09-21
D169CC00001/E0201004    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    04-02-20
D169CC00001/E0201007    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    20-05-21
D169CC00001/E0201025    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    04-06-20
D169CC00001/E0201025    HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT    04-06-20
;
run;

data se;
input usubjid :$40 EPOCH :$200 SESTDTC :yymmdd10. SEENDTC :yymmdd10.;
format SESTDTC SEENDTC yymmdd10.;
datalines;
USUBJID	EPOCH	SESTDTC	SEENDTC
D169CC00001/E0201004    SCREENING	        07-02-19	12-02-19
D169CC00001/E0201004	BLINDED TREATMENT	12-02-19	15-09-21
D169CC00001/E0201007	SCREENING	        01-04-19	08-04-19
D169CC00001/E0201007	BLINDED TREATMENT	08-04-19	 
D169CC00001/E0205038	SCREENING	        12-09-19	19-09-19
D169CC00001/E0205038	BLINDED TREATMENT	19-09-19	20-02-20
D169CC00001/E0205038	FOLLOW-UP	        20-02-20	 
D169CC00001/E0201025	SCREENING	        26-09-19	03-10-19
D169CC00001/E0201025	BLINDED TREATMENT	03-10-19	08-01-20
D169CC00001/E0201025	FOLLOW-UP	        08-01-20
;
run;

/* From Above two data set are left joined by below code. */
/*before left join created one unique id in CE data */
/*for final output records same as first CE data */

data ce;
  set ce;
  seq_id=_n_;
run;

proc sql;
 create table ce_and_se as
 select a.*,b.epoch,b.sestdtc,b.seendtc
 from ce as a left join se as before on a.usubjid=b.usubjid;
quit;

Output data set as below:
1. Output data set have same observation from first CE data.
2. EPOCH values will be assinged based on date when SESTDTC <= cestdtc < SEENDTC.
3. if cestdtc is missing then epoch will missing values.
4. if  SESTDTC <= cestdtc < SEENDTC this logic not fall then print those values to log (only when cestdtc and SESTDTC and SEENDTC not missing)

/*Final output like below:*/
/*data have */
USUBJID	ceterm	cestdtc	EPOCH
D169CC00001/E0201004	CV DEATH	14-09-21	
D169CC00001/E0201004	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	04-02-20	BLINDED TREATMENT
D169CC00001/E0201004	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	03-09-21	BLINDED TREATMENT
D169CC00001/E0201004	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	04-02-20	BLINDED TREATMENT
D169CC00001/E0201007	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	20-05-21	BLINDED TREATMENT
D169CC00001/E0201025	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	04-06-20	FOLLOW-UP
D169CC00001/E0201025	HEART FAILURE HOSPITALIZATION/URGENT HEART FAILURE VISIT	04-06-20	FOLLOW-UP







How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 15 replies
  • 2828 views
  • 3 likes
  • 3 in conversation