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.
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
I am not clear as to what your problem is exactly. Which of the following conditions apply to your case. You get missing values...
PG
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.
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;
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.
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
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!
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.