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!
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.
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.
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.
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;
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!
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.
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.