DATA Step, Macro, Functions and more

treatment lines

Reply
Contributor
Posts: 29

treatment lines

This is what i have 

 

ObsPatientIDepisode_start_1episode_end_1episode_start_2episode_end_2episode_start_3episode_end_3episode_start_4episode_end_4episode_start_5episode_end_5episode_start_6episode_end_6episode_start_7episode_end_7episode_start_8episode_end_8
1F000678A987922/1/20167/30/2016..............
2F002F4C07392F8/19/20152/15/2016..............
3F002F4C07392F8/19/20152/15/20162/16/20168/14/2016............
4F00314B361B6A11/28/20165/27/2017..............
5F00314B361B6A11/28/20165/27/20175/28/201711/24/2017............
6F003E7ADEB2F81/20/20172/15/2017..............

 

 

 

This is what i want to see 

ObsPatientIDep_step_endep_treatment_flagepisode
1F000678A9879202/01/201607/30/201651
2F002F4C07392F08/19/201502/15/201631
3F002F4C07392F02/16/201608/14/201632
4F00314B361B6A11/28/201605/27/201751
5F00314B361B6A05/28/201711/24/201752
6F00314B361B6A11/25/201705/24/201823
7F003E7ADEB2F801/20/201707/19/201751

 I do not care about the treatment flag or episode.. just need the dates for ep_st and ep_end to match with my episode_start_1 episode_end_1... episode_start_2 episode_end_2... 

 

for the patient id - F00314B361B6A i only have two observations, whereas i should be getting three, 

 

 I want SAS to divide each one into intervals of 6 months.. according to a rule... the code is written below, the code is right,, i just need to add one more statement to it.. I do not know what that should be :-

 

any help or suggestion is appreciated 

 

 

 

Regular Contributor
Posts: 180

Re: treatment lines

something like this would work...

 

proc sql; select Obs,    PatientID,    episode_start_1    as ep_st, episode_end_1 as ep_end from foo
union select  Obs,    PatientID,    episode_start_2, episode_end_2 from foo
union select  Obs,    PatientID,    episode_start_3, episode_end_3 from foo

 

and so on.

New Contributor
Posts: 2

Re: treatment lines

Try this.

 

%macro process();
	data output (keep=PatientID ep_st ep_end);
		format PatientID $CHAR13. ep_st mmddyy8. ep_end mmddyy8.;
		set test; /*Your input file*/
		%do i = 1 %to 8;
			if (episode_start_&i. ne . and episode_end_&i. ne .) then do;
				ep_st = episode_start_&i.;
				ep_end = episode_end_&i.;
				output;
			end;
		%end;
	run;
%mend;
%process;
Ask a Question
Discussion stats
  • 2 replies
  • 59 views
  • 0 likes
  • 3 in conversation