BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sas9
Calcite | Level 5

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
PGStats
Opal | Level 21

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

6 REPLIES 6
PGStats
Opal | Level 21

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
sas9
Calcite | Level 5

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.

Rick_SAS
SAS Super FREQ

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;

sas9
Calcite | Level 5

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.

PGStats
Opal | Level 21

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
sas9
Calcite | Level 5

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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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