I have amount columns as below, few amount column is 0(Zero) values, and some are more than Zero. I do not want Zero values from amount column. proc contents as below.
# | Variable | Type | Len | Format | Informat | Label |
---|---|---|---|---|---|---|
5 | amount | Num | 8 | 18. |
When I am using as below, still I see amount 0 is there in output and not deleting. May I know what I am missing here in condition.
data want;
set have;
if amount=o then delete;
run;
Your example code does not have a zero in it. Instead it has a lowercase letter O.
Try using zero instead.
data want;
set have;
if amount=0 then delete;
run;
If that still show some values as zero then perhaps they are between -0.5 and 0.5 since you asked SAS to display the values as integers by attaching the display format of 18. to the variable.
Try using the ROUND() function to round the value to an integer before comparing it to zero.
data want;
set have;
if round(amount,1)=0 then delete;
run;
Or perhaps you should display the values with a different format so you can see if they have something other then zero there that you might want to keep?
proc freq data=have;
tables amount ;
format amount best18.;
run;
Your example code does not have a zero in it. Instead it has a lowercase letter O.
Try using zero instead.
data want;
set have;
if amount=0 then delete;
run;
If that still show some values as zero then perhaps they are between -0.5 and 0.5 since you asked SAS to display the values as integers by attaching the display format of 18. to the variable.
Try using the ROUND() function to round the value to an integer before comparing it to zero.
data want;
set have;
if round(amount,1)=0 then delete;
run;
Or perhaps you should display the values with a different format so you can see if they have something other then zero there that you might want to keep?
proc freq data=have;
tables amount ;
format amount best18.;
run;
If this:
data want;
set have;
if amount=o then delete;
run;
is really your code, then the log will most probably tell you that variable o is uninitialized, unless o is also contained in dataset have.
o was typo, I mean if amount=0 then delete;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.