This is what i have
Obs | PatientID | episode_start_1 | episode_end_1 | episode_start_2 | episode_end_2 | episode_start_3 | episode_end_3 | episode_start_4 | episode_end_4 | episode_start_5 | episode_end_5 | episode_start_6 | episode_end_6 | episode_start_7 | episode_end_7 | episode_start_8 | episode_end_8 |
1 | F000678A98792 | 2/1/2016 | 7/30/2016 | . | . | . | . | . | . | . | . | . | . | . | . | . | . |
2 | F002F4C07392F | 8/19/2015 | 2/15/2016 | . | . | . | . | . | . | . | . | . | . | . | . | . | . |
3 | F002F4C07392F | 8/19/2015 | 2/15/2016 | 2/16/2016 | 8/14/2016 | . | . | . | . | . | . | . | . | . | . | . | . |
4 | F00314B361B6A | 11/28/2016 | 5/27/2017 | . | . | . | . | . | . | . | . | . | . | . | . | . | . |
5 | F00314B361B6A | 11/28/2016 | 5/27/2017 | 5/28/2017 | 11/24/2017 | . | . | . | . | . | . | . | . | . | . | . | . |
6 | F003E7ADEB2F8 | 1/20/2017 | 2/15/2017 | . | . | . | . | . | . | . | . | . | . | . | . | . | . |
This is what i want to see
Obs | PatientID | ep_st | ep_end | ep_treatment_flag | episode |
1 | F000678A98792 | 02/01/2016 | 07/30/2016 | 5 | 1 |
2 | F002F4C07392F | 08/19/2015 | 02/15/2016 | 3 | 1 |
3 | F002F4C07392F | 02/16/2016 | 08/14/2016 | 3 | 2 |
4 | F00314B361B6A | 11/28/2016 | 05/27/2017 | 5 | 1 |
5 | F00314B361B6A | 05/28/2017 | 11/24/2017 | 5 | 2 |
6 | F00314B361B6A | 11/25/2017 | 05/24/2018 | 2 | 3 |
7 | F003E7ADEB2F8 | 01/20/2017 | 07/19/2017 | 5 | 1 |
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
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.
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.