BookmarkSubscribeRSS Feed
RM121
Calcite | Level 5

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;

2 REPLIES 2
Jagadishkatam
Amethyst | Level 16
any sample data would help for better response
Thanks,
Jag
ballardw
Super User

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
;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 314 views
  • 0 likes
  • 3 in conversation