Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- Graphics
- /
- plot mean with std error

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 04-29-2013 03:06 PM
(1528 views)

I am trying to take the mean of the log of a variable. There are some values of the variable which is 1. so the log value will be "0"(zero) value . then i am supposed to take the mean of all the values that contains some '0' too and plot against std error. so when i do proc means i get missing mean as well as std error . i am suppose to plot this mean of the log value of the variable with the std error. Can anyone please guide me to overcome this problem.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Your second step doesn't use the dataset named ds created in the first step. Try this instead

**data ds(keep =usubjid dose1);****set datax;****where dose > 0 ;****dose1 =log(dose);****run;**

**proc means data=ds ;****by usubjid;****var dose1;****output out =datax1 n=n mean=mean stderr=stderr;****run;**

PG

PG

6 REPLIES 6

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

I am not clear as to what your problem is exactly. Which of the following conditions apply to your case. You get missing values...

- in the log-transformed value because the value is <= 0
- in the mean because the log-transformed values are all missing
- in the std because the mean is missing or there is only one nonmissing value

PG

PG

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thankx for reaching out to me. I do have logarithmic values of the variable as zero since there are some values of the variable which are 1 and when i take log(1) it gives me zero.further to that i take mean of the log value of the variable and st error . the mean as well as stderror comes as missing.

all i want to do is take the log of a variable and then plot mean of the log with the stderror.but the variable has some 1 values.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

I still don't understand the issue. Here are some data that have been log-transformed. The results of PROC MEANS are not missing. Can you modify my DATA step to mimic the data that you have? Or can you explain how your analysis is different ?

data A;

input x @@;

logX = log(x);

datalines;

0 1 2 3 4 5 4 0 3 2 1 2 3

;

proc means data=A mean std;

var logX;

run;

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thank you Rick for getting back to me.

variable(dose) values are for example 1 1 1 1 1 1.5 1.6 ...

data ds(keep =usubjid dose);

set datax;

where dose ne . ;

dose1 =log(dose);

run;

when i do this where ever dose values are equal to 1 i get dose1 =0

i get a note in logafter i run that part of the code as "mathematical operations could not be performed "and there is "an invalid argument to function log".

then i did

proc means data =datax ;

by usubjid;

var dose1;

output out =datax1 n=n mean=mean stderr=stderr;

run;

the datax1 dataset has values where mean=o and std err=0 and also some values where stderr =missing.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Your second step doesn't use the dataset named ds created in the first step. Try this instead

**data ds(keep =usubjid dose1);****set datax;****where dose > 0 ;****dose1 =log(dose);****run;**

**proc means data=ds ;****by usubjid;****var dose1;****output out =datax1 n=n mean=mean stderr=stderr;****run;**

PG

PG

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thank you.. your idea of >0 removed the log problem.

I did use the correct dataset in my program but i guess typed it wrong in the sample code that i sent. I am sorry .Thank you very much though.

**SAS Innovate 2025** is scheduled for May 6-9 in Orlando, FL. Sign up to be **first to learn** about the agenda and registration!

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.

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