Hello,
I have a numeric variable that is 6 numbers in length. I'd like to use SQL to only keep the numbers that are 3 digits long. So, for example, I would keep 123 but not 1234 or 12345 or 123456.
Thanks.
In SQL, have it filter for any value between 100 and 999.
In SQL, have it filter for any value between 100 and 999.
So now the question is if the variable is character, how do I filter on that?
@NickK wrote:
So now the question is if the variable is character, how do I filter on that?
where length(variablename) =3
unless you have leading spaces in your character variable, then you need to STRIP the variable to remove leading spaces if you do not want to count them.
Do you consider a character string of 003 to be 3 digits or 1 digit?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.