## Programming the statistical procedures from SAS

Occasional Contributor
Posts: 13

Hello!

I'm working on some pilot data and naturally I have a non-normal distribution for my outcome. I tried to alleviate this by converting my outcome (continuous) variable to a log base 10 variable. Unfortunately, one of my outcome variables is 0 so SAS gives me the "NOTE: Invalid argument to function LOG10 at line nnn column nn" error message and then treats that variable as missing. Is there a way to solve this?

I made the new variable in a "set" statement so the ?? modifier doesn't seem to work.

Any advice would be much appreciated (I'm a freshie, go easy on me)!

Super User
Posts: 20,730

## Re: Question about log-based variables

Well, its true, you can't take the log of 0.

One simple way is to add 0.1 to the 0, if that's valid.

Depending on the data there may be other transformations or methods that are available.

data want;

set have;

if pilot=0 then pilot2=0.1;

logpilot=log10(pilot2);

run;

Occasional Contributor
Posts: 13

## Re: Question about log-based variables

Thanks Reeza jan, I didn't realize a few hours ago that this was a conventional way of solving the problem

Posts: 5,046

## Re: Question about log-based variables

Logarithmic transformation would make sense for your data if zero values actually mean that the value was too small to be measured. In that case, many analysts will replace zeros with half the smallest value that can be measured, before taking the logarithm.

Taking logarithms is only one of many ways to deal with non-normal data. We would need to know more about the nature of your data to suggest other methods.

PG

PG
Occasional Contributor
Posts: 13

## Re: Question about log-based variables

In my case zero just means that the value was actually zero. Values that were too small to be measured were treated as missing data.

Posts: 5,046

## Re: Question about log-based variables

```sara.a wrote:

Values that were too small to be measured were treated as missing data.
```

That amounts to left censoring. Wouldn't that automatically create an upward bias in your location (mean, median, etc.) estimates?

PG
Occasional Contributor
Posts: 13

## Re: Question about log-based variables

I can see how it could cause that...but I'm not sure what else to do. Because for those observations not enough biological sample was obtained for a proper measurement to be taken.

Super User
Posts: 10,207

## Re: Question about log-based variables

Are you trying to do some  Regression ? Check Box transformation

OR use proc tranreg which is designed for such purpose .

SAS Super FREQ
Posts: 3,839

## Re: Question about log-based variables

Discussion stats
• 8 replies
• 386 views
• 9 likes
• 5 in conversation