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

Hi All,

Is it possible find some value that can be in any tables column , without manually coding(macro etc.)?

For example, there is some table with 20 columns and I should make the query that shoud retutn all rows if any of the columns has some searching value...

Off cource I can make some workaround - f.e. macro that merge all columns into one character col and then just search for a needed value in this column, but may be there are some standard approcah in SAS for such cases?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Data_Detective_23219
Calcite | Level 5

Ron Cody and Jeff Smith's book Applied Statistics and the Sas Programming Language (Chapter 15 of the 4th edition) shares two arrays (one for character and one for numeric) intended to render the process you describe. 

View solution in original post

4 REPLIES 4
Data_Detective_23219
Calcite | Level 5

Ron Cody and Jeff Smith's book Applied Statistics and the Sas Programming Language (Chapter 15 of the 4th edition) shares two arrays (one for character and one for numeric) intended to render the process you describe. 

Yura2301
Quartz | Level 8

Hi,

Thanks for the tip,  I believe that this solution actually what is needed, but I didn’t found some free version of the book:), so if there are some “light” free version of the book and you have the link – please share:)

Anyway thanks, at least now I know the most optimal solution for the task.

Reeza
Super User

If you're looking for a number or word that would be the entire variables value then you can use the whichc or whichn function coupled with the _numeric_ or _character_ shortcuts.  If the string can be only part of a variable then you need a different solution.

data want_numeric;

set sashelp.class;

if whichn(15, of _numeric_);

run;

data want_character;

set sashelp.class;

if whichc('F', of _character_);

run;

Yura2301
Quartz | Level 8

Hi Reeza,

Thanks for answer, your solution is very close to what is needed, but, as you supposed in your post, - I should make search in both char and numeric variable, and obviously char variables can have some numeric value etc.

But anyway thanks, I'm sure that I'll use these function in some future tasks.

Thanks!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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