I'm using the code below to find is a patient who had an appendectomy also had a diagnosis of appendicitis within 30 days of the procedure. The code below doesn't seem to be working as expected. It is correctly flagging those with a diagnosis but not the 30-day AND part. Can anyone spot what's wrong?
array dx[10] DX1 - DX10;
appdx_flag = 0;
chronic_flag = 0;
do i = 1 to 10;
if (left(trim(substr(dx[i],1,5))) in (&AppICD9Codes4)) and (ENC_DATE - DxWindow) <= 30 then
appdx_flag = 1;
end;
Thanks,
Brian
Hi:
I'm curious about the DX1-DX10 variables are they character or numeric? generally, you don't use substr on a numeric variable. So I'm sort of surprised that your left(trim(substr isn't giving your automatic conversion messages in the log:
NOTE: Numeric values have been converted to character values at the places given by: (Line) : (Column).
NOTE: Character values have been converted to numeric values at the places given by: (Line) : (Column).
Aside from any issues of your date values in the IF, problems with the substr function could cause the IF not to work correctly.
cynthia
You should provide some example data. You don't show what types of values ENC_DATE and DxWindow are or what the values look like. Some of the more common questions relate to date values and if your variables are not actually date values then the subtraction would likely be incorrect.
So provide some example data, best in the form of a datastep so we can test code. This link
shows one way to turn your dataset into a data step.
If you give two or three records(even fictious), then it will easy to visualize the problem. You use IN function with a macro variable. Is it a list?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.