SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
_maldini_
Barite | Level 11

Can you define a range using the IN statement? Documentation says "yes", but my syntax says "no". 

  where RXDDCI1A in (40,358);
  where same and RXDDCI1B in (41-56,303,340,342,430,433,482,483,19);

The above syntax selects 1 observation where RXDDCI1B=41 and then picks back up when RXDDCI1B=303. It works as desired when I remove the range (i.e., 41, 42, 43, 44, etc.).

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Documentation says that the integer sequence is indicated by a full colon

 

 where same and RXDDCI1B in (41:56,303,340,342,430,433,482,483,19);

 

I say sequence because that is what that would be 41, 42 etc. A range would be anything between 41 and 56, such as 41.345678 but IN really want to use a finite list of values.

View solution in original post

2 REPLIES 2
ballardw
Super User

Documentation says that the integer sequence is indicated by a full colon

 

 where same and RXDDCI1B in (41:56,303,340,342,430,433,482,483,19);

 

I say sequence because that is what that would be 41, 42 etc. A range would be anything between 41 and 56, such as 41.345678 but IN really want to use a finite list of values.

Cynthia_sas
SAS Super FREQ

@ballardw is correct, you need the colon : to indicate a range. The SAS log notes reveal the issue with trying - for the range indicator, as shown in the simplified example below:

Cynthia_sas_0-1656547568368.png

 

Cynthia

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1576 views
  • 4 likes
  • 3 in conversation