Happy Monday All!
So here is my questions that I hope can be solved with relative ease-
I have an array that works in that it calculates if notetime{i} is between the Unit_startTime_Day & Unit_EndTime_Day, tallies the sum of the entries that match and then keeps the notetimes that match the condition
But here is what I am trying to do-
In line2, I am trying to make it so that notetime4 becomes notetime1, notetime5 becomes notetime2, etc etc as there can be up to x number of notes but it becomes difficult for users to scroll through when its note22-note1000
code below table- I apologize in advance that there is no input table but hopefully someone can point me to the way...
Thanks in advance for your help.
LB
data all_notes;
retain date time_days pt_hours total_notes;
merge unit_time note_times;
by PAT_ENC_CSN_ID;
array notes (*) note:;
array notep {¬ect};
array notetime {¬ect};
do i=1 to dim(notes);
if start2<=notes(i)<=end_t then notep(i)=1; else notep(i)=0;
if notep(i)=1 then notetime(i)=notes(i);else notetime(i)=.;
end;
total_notes=sum(of notep1-notep¬ect);
format notetime1-notetime¬ect datetime19.;
drop _name_ _label_ note1-note¬ect /*notep1-notep¬ect* i*/ department_id DEPARTMENT_NAME tot_hrs;
rename start2=Unit_StartTime_Day END_T=Unit_EndTime_Day time_days=pt_days;
if department_id=. then delete;
run;
pat_enc_csn_id | Unit_StartTime_Day | Unit_EndTime_Day | notetime1 | notetime2 | notetime3 | notetime4 | notetime5 | notetime6 | notetime7 |
1234 | 24Jul18:04:19:00 | 24Jul18:23:59:59 | 24Jul18:02:35:00 | 24Jul18:08:42:00 | 24Jul18:22:58:00 | . | . | . | . |
1234 | 25Jul18:00:00:00 | 25Jul18:23:59:59 | . | . | . | 25Jul18:03:25:00 | 25Jul18:08:18:00 | . | . |
Not too sure I understand but this might to do what you want:
data HAVE;
infile cards dlm='09'x dsd;
input PAT_ENC_CSN_ID (UNIT_STARTTIME_DAY UNIT_ENDTIME_DAY NOTETIME1 NOTETIME2 NOTETIME3 NOTETIME4 NOTETIME5 NOTETIME6 NOTETIME7) (: datetime16.);
format UNIT_STARTTIME_DAY UNIT_ENDTIME_DAY NOTETIME1 NOTETIME2 NOTETIME3 NOTETIME4 NOTETIME5 NOTETIME6 NOTETIME7 datetime.;
cards;
1234 24Jul18:04:19:00 24Jul18:23:59:59 24Jul18:02:35:00 24Jul18:08:42:00 24Jul18:22:58:00 . . . .
1234 25Jul18:00:00:00 25Jul18:23:59:59 . . . 25Jul18:03:25:00 25Jul18:08:18:00 . .
run;
data WANT;
set HAVE;
array NOTES [*] NOTETIME: ;
array NOTEP [7] ;
array NOTETIME [7] NEW1-NEW7;
format NEW: datetime.;
POS=1;
do I=1 to 7;
if UNIT_STARTTIME_DAY <= NOTES[I] <= UNIT_ENDTIME_DAY then do;
NOTEP[I]=1;
NOTETIME[POS]=NOTES[I];
POS+1;
end;
end;
TOTAL_NOTES=sum(of NOTEP1-NOTEP7);
run;
proc print noobs;
var PAT_ENC_CSN_ID NEW:;
run;
PAT_ENC_CSN_ID | NEW1 | NEW2 | NEW3 | NEW4 | NEW5 | NEW6 | NEW7 |
---|---|---|---|---|---|---|---|
1234 | 24JUL18:08:42:00 | 24JUL18:22:58:00 | . | . | . | . | . |
1234 | 25JUL18:03:25:00 | 25JUL18:08:18:00 | . | . | . | . | . |
Not too sure I understand but this might to do what you want:
data HAVE;
infile cards dlm='09'x dsd;
input PAT_ENC_CSN_ID (UNIT_STARTTIME_DAY UNIT_ENDTIME_DAY NOTETIME1 NOTETIME2 NOTETIME3 NOTETIME4 NOTETIME5 NOTETIME6 NOTETIME7) (: datetime16.);
format UNIT_STARTTIME_DAY UNIT_ENDTIME_DAY NOTETIME1 NOTETIME2 NOTETIME3 NOTETIME4 NOTETIME5 NOTETIME6 NOTETIME7 datetime.;
cards;
1234 24Jul18:04:19:00 24Jul18:23:59:59 24Jul18:02:35:00 24Jul18:08:42:00 24Jul18:22:58:00 . . . .
1234 25Jul18:00:00:00 25Jul18:23:59:59 . . . 25Jul18:03:25:00 25Jul18:08:18:00 . .
run;
data WANT;
set HAVE;
array NOTES [*] NOTETIME: ;
array NOTEP [7] ;
array NOTETIME [7] NEW1-NEW7;
format NEW: datetime.;
POS=1;
do I=1 to 7;
if UNIT_STARTTIME_DAY <= NOTES[I] <= UNIT_ENDTIME_DAY then do;
NOTEP[I]=1;
NOTETIME[POS]=NOTES[I];
POS+1;
end;
end;
TOTAL_NOTES=sum(of NOTEP1-NOTEP7);
run;
proc print noobs;
var PAT_ENC_CSN_ID NEW:;
run;
PAT_ENC_CSN_ID | NEW1 | NEW2 | NEW3 | NEW4 | NEW5 | NEW6 | NEW7 |
---|---|---|---|---|---|---|---|
1234 | 24JUL18:08:42:00 | 24JUL18:22:58:00 | . | . | . | . | . |
1234 | 25JUL18:03:25:00 | 25JUL18:08:18:00 | . | . | . | . | . |
perfect! Thanks!
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: