Data visualization with SAS programming

plot mean with std error

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

plot mean with std error

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.


Accepted Solutions
Solution
‎04-29-2013 10:36 PM
Respected Advisor
Posts: 4,606

Re: plot mean with std error

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

View solution in original post


All Replies
Respected Advisor
Posts: 4,606

Re: plot mean with std error

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

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

PG

PG
New Contributor
Posts: 4

Re: plot mean with std error

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.

SAS Super FREQ
Posts: 3,406

Re: plot mean with std error

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;

New Contributor
Posts: 4

Re: plot mean with std error

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.

Solution
‎04-29-2013 10:36 PM
Respected Advisor
Posts: 4,606

Re: plot mean with std error

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
New Contributor
Posts: 4

Re: plot mean with std error

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.

☑ This topic is SOLVED.

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

Discussion stats
  • 6 replies
  • 397 views
  • 1 like
  • 3 in conversation