BookmarkSubscribeRSS Feed
manya92
Fluorite | Level 6

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 

 

 

 

2 REPLIES 2
tomrvincent
Rhodochrosite | Level 12

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.

Ramesh_165
Obsidian | Level 7

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 562 views
  • 0 likes
  • 3 in conversation