Hi,
I have eGFR data with multiple eGFR values per patient. And I want to select the eGFR value closest to diagnosis date (+-2 months). And for patients with multiple values in +-2 months period I want to select the eGFR value prior to diagnosis and closest to diagnosis date. I am not able to write the code for the "elect the eGFR value prior to diagnosis and closest to diagnosis ". Appreciate any help I can get.
Here is the code I have so far:
data Y;
set X;
CalCreDiff=eGFRdate-DX_DATE;
AbsCaleGFRDiff=abs(CalCreDiff);
if -60<=AbseCaleGFRDiff=<60;
run;
The code you are attempting is about 2 lines longer than it needs to be. Unless you later that need one or more of the AbsCaleGFRDiff or CalCreDiff variables then do the arithmetic inside the ABS function.
Also you only need one side for the comparison.
data example; input x y; if abs(x - y) le 60 then put "Between -60 and 60"; else put "Out of range"; datalines; 120 60 120 59 120 61 0 -61 0 -60 0 -59 ;
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.