BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
wlierman
Lapis Lazuli | Level 10

I have nine diagnosis code attributes (columns) labeled Diag1, Diag2,  ..... , Diag9

 

I have several icd-10 dx_codes that I need to check across 3 years of Medicaid recipient claims

 

Here is the c ode starting after the FROM clause

 

WHERE Month Between '201701' And '201912'

    And ClaimType Not In ('D')

    And  Diag1 - Diag9 In ('B20', 'B9735', ........., '09873')

ORDER By Recipno, Month;

quit;

 

The problem occurs at Diag1- Diag9  with the error reading:

Expression using negation (-) requires numeric types

 

I have tried several variants of the Diag1-DIag9 construct but none have solved the issue.

I appreciate your help again.

 

Walt Lierman

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Variable lists do not work in SQL code, only in regular SAS code, that is why it thought you wanted subtraction.

But even if they did work your syntax will not work.  SAS does not have a syntax for test M variables for N values.

 

You need to list all of the test separately.

WHERE Month between '201701' and '201912'
    and ClaimType Not In ('D')
    and (Diag1 in ('B20', 'B9735', ........., '09873')
      or Diag2 in ('B20', 'B9735', ........., '09873')
   ...
      or Diag9 in ('B20', 'B9735', ........., '09873')
        )

 

View solution in original post

4 REPLIES 4
PGStats
Opal | Level 21

You can't use variable lists in proc SQL. Try the condition

 

And
whichc(Diag1, 'B20', 'B9735', ........., '09873') +
whichc(Diag2, 'B20', 'B9735', ........., '09873') +
whichc(Diag3, 'B20', 'B9735', ........., '09873') +
whichc(Diag4, 'B20', 'B9735', ........., '09873') +
whichc(Diag5, 'B20', 'B9735', ........., '09873') +
whichc(Diag6, 'B20', 'B9735', ........., '09873') +
whichc(Diag7, 'B20', 'B9735', ........., '09873') +
whichc(Diag8, 'B20', 'B9735', ........., '09873') +
whichc(Diag9, 'B20', 'B9735', ........., '09873') > 0

 

which is probably more efficient than a condition involving the OR operator.Diag1 in (...) OR Diag2 in (...) ...

PG
Tom
Super User Tom
Super User

Variable lists do not work in SQL code, only in regular SAS code, that is why it thought you wanted subtraction.

But even if they did work your syntax will not work.  SAS does not have a syntax for test M variables for N values.

 

You need to list all of the test separately.

WHERE Month between '201701' and '201912'
    and ClaimType Not In ('D')
    and (Diag1 in ('B20', 'B9735', ........., '09873')
      or Diag2 in ('B20', 'B9735', ........., '09873')
   ...
      or Diag9 in ('B20', 'B9735', ........., '09873')
        )

 

wlierman
Lapis Lazuli | Level 10
Thank you for your help on this.
Appreciate it very much.
wlierman
Lapis Lazuli | Level 10

Thank you Tom.

 

I appreciate your time and effort and correction.

 

Walt L

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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