Reputation: 27
I have a dataset named b
about various customer named as a1
,a2
,a45
,a345
,a999
,a654
, etc.
I would like to select customer named between a1
-a100
and discard others.
I tried this code:
data a;
set b;
where customer ne a1-a100;
run;
But I am getting this error
ERROR: Variable a1 is not on file b.
Upvotes: 1
Views: 150
Reputation: 3845
Convert the digits in your customer identifier to a number and apply the condition on that number.
data a;
set b;
if 1 le input(substr(customer,2),8.) le 100;
run;
substr(customer,2),8.
returns a the 2de till the last character from customer
, i.e. the digitsinput(substr(customer,2),8.)
interpretes the digits as a number1 le input(substr(customer,2),8.) le 100
is the sas way to write input(substr(customer,2),8.) between 1 and 100
(and it is actually better, as it allows using lt
in stead of le
too)if
without then
is in this case equivalent to where
. Upvotes: 2