BookmarkSubscribeRSS Feed
apple
Calcite | Level 5

I have A (numeric variable).

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

How do I write the code?

Thank you

3 REPLIES 3
Imroze
Fluorite | Level 6

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

Murray_Court
Quartz | Level 8

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;

pradeepalankar
Obsidian | Level 7

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

;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 450 views
  • 0 likes
  • 4 in conversation