BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sasg
Calcite | Level 5

Hi,

    I have a Product(coloumn) in the dataset(test).....which have values like this

    product

    000112

    22431

    123456

     0

    03456

   I would like to delete row contains 0 value....how could i do that,is there any function?

  

   output should be like this

  

    product

    000112

    22431

    123456

    03456

Thanks,

rk.

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Since you've already run what you want, you can do the other the same way:

data dontwant;

  set have (where=(strip(product) eq "0"));

run;

Of course, if you wanted to do it all in one step:

data want dontwant;

  set have;

  if strip(product) eq "0" then output dontwant;

  else output want;

run;

View solution in original post

4 REPLIES 4
art297
Opal | Level 21

There are a number or ways and it will depend upon the type of field, etc.  I'm going to guess that it is a character field and you can get away with something as simple as:

data want;

  set have (where=(strip(product) ne "0"));

run;

sasg
Calcite | Level 5

Hi,

     Thanks.....It worked....but if i want to send values with 0 into another file. how can i do that?

Thanks,

rk.

art297
Opal | Level 21

Since you've already run what you want, you can do the other the same way:

data dontwant;

  set have (where=(strip(product) eq "0"));

run;

Of course, if you wanted to do it all in one step:

data want dontwant;

  set have;

  if strip(product) eq "0" then output dontwant;

  else output want;

run;

sasg
Calcite | Level 5

Thanks art297......it worked.

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
  • 4 replies
  • 872 views
  • 0 likes
  • 2 in conversation