BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Planck
Obsidian | Level 7

Oh ok thanks for answer,

 

I am used to put some commas. But even, when I try your method i get an error.

 

The first query works well. I get the result: 1 5 13

But after when I run the second query so I have:

WHERE mydata IN (1 5 13)

And I get the error:

ERROR: Expression using IN has components that are of different data types.

because mydata is character.

Reeza
Super User

If your data is character you need the quotes. 

Tom
Super User Tom
Super User

@Planck wrote:

Oh ok thanks for answer,

 

I am used to put some commas. But even, when I try your method i get an error.

 

The first query works well. I get the result: 1 5 13

But after when I run the second query so I have:

WHERE mydata IN (1 5 13)

And I get the error:

ERROR: Expression using IN has components that are of different data types.

because mydata is character.


The error message explains the problem.  You cannot use numeric literals in the IN list if the variable being compared is character. You need to use character literals.

WHERE mydata IN ("1" "5" "13")

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 17 replies
  • 2656 views
  • 1 like
  • 4 in conversation