CATS (X) not starting with 111

Reply
Frequent Contributor
Posts: 75

CATS (X) not starting with 111

I have A (numeric variable).

I don't all records where A start with 111.

How do I write the code?

Thank you

Contributor
Posts: 62

Re: CATS (X) not starting with 111

HI apple,

Hope the below code is what you are looking for.

x=cats('111',variable_name);

put x=;

if the above code does not work please convert the numeric variable to char by using put() ...

EX:

y=put(variable_name,8.);

x=cats('111',y);

put x=;

Thank You

Contributor
Posts: 45

Re: CATS (X) not starting with 111

If you want to select any record which does not begin with '111' then use the folling code;

Data want;

set have;

y=put(a,8.);

z=substr(y,1,3);

if z="111" then delete;

run;

Frequent Contributor
Posts: 106

Re: CATS (X) not starting with 111

HI Try this,

If a is char:

data test;

input a $;

if a ^=: '111';

cards;

11122

12222

11111

31222

;

If a is numeric:

data test;

input a;

if cats(a) ^=: '111';

cards;

11122

12222

11111

31222

;

Ask a Question
Discussion stats
  • 3 replies
  • 185 views
  • 0 likes
  • 4 in conversation