BookmarkSubscribeRSS Feed
Tushh
Calcite | Level 5

Hi,

 

 

i have dataset from which i want to delete Entire ROWS WHich columns contails following values.(zero, zeros with decimal point & Dot)

 

 

0   -: zero

 

0.000  -: Zeros with decimal

.    -: Dot

 

can i have solution on this? thank you

8 REPLIES 8
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Then you would use if, where, select or any other conditional statements:

data want;

  set have;

  if <variable> in (.,0) then delete;  /* Assuming numeric  */

  if <variable> in (".","0","0.000") then delete;  /* Assuming character */

run;

 

Or:

data want;

  set have (where=(<variable> not in (.,0) or <variable> not in (".","0","0.000")));

run;

Pamela_JSRCC
Quartz | Level 8

If the variable is numeric, you may want to round the value, especially if it is the result of a computation.  Sometimes floating point caculations result in values so close to zero, that you want to treat them as zero.

Astounding
PROC Star

You say you have a data set ... but is it already a SAS data set?  (It would be extremely unusual for a variable to contain "0.000" in a SAS data set, but it is possible.)

 

Are you looking to apply these conditions to character variables as well?  What if the character variable is merely blank and doesn't contain a dot?

 

 

data_null__
Jade | Level 19

@Astounding wrote:

You say you have a data set ... but is it already a SAS data set?  (It would be extremely unusual for a variable to contain "0.000" in a SAS data set, but it is possible.)

 

 


That's mostly right  zero is zero but it can be made to appear as 0.000

 

40         data _null_;
41            x = 0;
42            put x=f5.3;
43            run;

x=0.000

 

FreelanceReinh
Jade | Level 19

Formatted values can also conceal the true values. So, "0.000" could in fact be 0.000456 (or, in the worst case, something completely different, depending on the format definition).

 

Another potential issue: If you are dealing with numeric values which have been converted to character values, there is a high probability of leading blanks.

 

Please see the examples below:

data have;
do x=., 0, 0.000456; /* numeric */
  xf=x;              /* numeric, formatted (see FORMAT statement) */
  t=put(x, 6.3);     /* character */
  c='#'||t||'#';     /* just to make blanks visible */
  output;
end;
format xf 6.3;
proc print;
run;

data want;
set have;
if x | xf | input(t, 30.);
run;

A numeric value can be used as an IF condition: It is evaluated as true if and only if it is neither zero nor missing.

 

 

Ksharp
Super User

data have;
input x $20.;
if missing(x) then x=.;
cards;
0
00
0.
0.00
0.000
.
..
12
;
run;
data want;
 set have;
 if prxmatch('/^0+$|^0+\.0*$|^\.+$/',strip(x)) then delete;
run;
Tushh
Calcite | Level 5

 so much all of your efforts

 

 

 

issue is resolved now

Tushh
Calcite | Level 5

thank u so much

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 5270 views
  • 0 likes
  • 7 in conversation