BookmarkSubscribeRSS Feed
BTAinRVA
Quartz | Level 8

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

 

5 REPLIES 5
Cynthia_sas
SAS Super FREQ

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

ballardw
Super User

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

https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

shows one way to turn your dataset into a data step.

BTAinRVA
Quartz | Level 8
ballardw,
Thanks for the link. I'll try using that macro tomorrow.

Cynthia,
The dx variables are character.
KachiM
Rhodochrosite | Level 12

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?

BTAinRVA
Quartz | Level 8
datasp,
Yes, the macro variables are lists of diagnosis codes

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
  • 5 replies
  • 1036 views
  • 0 likes
  • 4 in conversation