DATA Step, Macro, Functions and more

delete zero value from character field

Accepted Solution Solved
Reply
Contributor
Posts: 42
Accepted Solution

delete zero value from character field

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.


Accepted Solutions
Solution
‎07-25-2011 06:06 PM
PROC Star
Posts: 7,474

delete zero value from character field

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


All Replies
PROC Star
Posts: 7,474

delete zero value from character field

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;

Contributor
Posts: 42

delete zero value from character field

Hi,

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

Thanks,

rk.

Solution
‎07-25-2011 06:06 PM
PROC Star
Posts: 7,474

delete zero value from character field

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;

Contributor
Posts: 42

delete zero value from character field

Thanks art297......it worked.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 194 views
  • 0 likes
  • 2 in conversation