06-11-2014 07:15 PM
I am trying to write an edit check that ensures that the value of one variable occurred at least 4 hours prior to a different variable value, and did not occur at all after a different variable. Here are the variables I have and what they mean:
subject = Subject
instm = Start Time of Insulin
baslintm = Time of Baseline Fingerstick
dischatm = Time of Discharge Fingerstick
I want the edit check to call out whenever the start time of insulin occurred at a time that was not at least 4 hrs prior to the time of the baseline fingerstick reading. I also want to ensure that the start time of insulin did not occur at all after the time of the discharge fingerstick. I am using a Proc SQL statement and I'm having trouble writing the "where" clause in a way that would do this. I am a SAS newbie and dont really know syntax well so any help would be appreciated.
Here is the code I have now:
proc sort data=tbl_insulin_list; by subject; run;
proc sort data=tblIn_Clinic_Day; by subject; run;
merge tbl_insulin_list tblIn_Clinic_Day;
create table &data67 as
select subject label='Subject|Number'
,instm label='Start Time of Insulin'
,baslintm label='Time of Baseline Fingerstick'format=time5.
,dischatm label='Time of Discharge Fingerstick'format=time5.
where instm=. | (instm >= (baslintm - (04:00)))| instm>= dischatm
06-11-2014 08:03 PM
The or operator depends on your OS, so make sure that | is valid for yours.
SAS time is measured in seconds so you can subtract the two and check that the duration is less than 4 hours, which is 60sec*60 mins*4 hours = 14400
I think what you want is:
OR (instm - baslintm) < 14400
OR instm >= dischatm;
06-11-2014 09:22 PM
From your description, I guess, it is more reasonable for your where clause:
where instm is not null and intck('minute', instm,baslintm)>240 and instm>=dischatm;