Skip to content
Advertisement

How to select numeric data of certain length

I am trying to select numeric data that is greater than 5 bytes. I have entered the below but get an error of ERROR: Function LENGTH requires a character expression as argument 1. Not sure what I am doing wrong. Any help would be greatly appreciated.

Advertisement

Answer

Since you are dealing with both credit card numbers and 5-digit numbers, let’s assume that all of them could be stored in one of three formats:

Let’s start with the first case, which assumes that the variable is numeric. You want to exclude all 5-digit values. You can use this trick by Rick Wicklin to count the number of digits in an integer:

For the second and third cases, they’ll be stored as characters. You can count the number of numeric characters in a string using countc() with the D option.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement