Hello, I am working in SAS Studio analyzing the HEART dataset. The below is my code. The boldened text is the problem code. The Logit_Dia variable is not returning any data back. Is there anything obvious I am missing here?
proc means data=out3 nway;
class mrw_group;
var mrw;
output out=Out4a Mean=CHD_Mean mean(mrw)=MRW_Mean;
run;
proc means data=out3 nway;
class height_group;
var height;
output out=Out4b Mean=CHD_Mean mean(height)=height_Mean;
run;
proc means data=out3 nway;
class weight_group;
var weight;
output out=Out4c Mean=CHD_Mean mean(weight)=weight_Mean;
run;
data out5a;
set out4a;
Logit_Dia = log( CHD_Mean / (1 - CHD_Mean) );
run;
data out5b;
set out4b;
Logit_Dia = log( CHD_Mean / (1 - CHD_Mean) );
run;
data out5c;
set out4c;
Logit_Dia = log( CHD_Mean / (1 - CHD_Mean) );
run;
We don't have access to your library libname heartlib "/home/u63742108/heartlib"; and the table in there is already a modified version of sashelp.heart
Anyway: I believe the issues identified are what you need to address. Run your code step by step, check the SAS log for any issues and fix the step until working properly before you test the next one.
What's also sometimes worth doing: Disconnect/reconnect to your SAS server so that a new SAS workspace session gets created and not some "leftover" from an earlier run in the same session impacts your current run.
The main things missing are
16 proc means data=sashelp.heart nway; 17 var mrw; 18 output out=mrw Mean=CHD_Mean ; 19 run; NOTE: There were 5209 observations read from the data set SASHELP.HEART. NOTE: The data set WORK.MRW has 1 observations and 3 variables. NOTE: PROCEDURE MEANS used (Total process time): real time 0.02 seconds cpu time 0.01 seconds 20 21 data mrw_logit; 22 set mrw; 23 Logit_Dia = log( CHD_Mean / (1 - CHD_Mean) ); 24 run; NOTE: Invalid argument to function LOG(-1.008406362) at line 23 column 15. _TYPE_=0 _FREQ_=5209 CHD_Mean=119.95752451 Logit_Dia=. _ERROR_=1 _N_=1 NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to missing values. Each place is given by: (Number of times) at (Line):(Column). 1 at 23:15 NOTE: There were 1 observations read from the data set WORK.MRW. NOTE: The data set WORK.MRW_LOGIT has 1 observations and 4 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.00 seconds
Since the MEAN of most of those variables is going to be larger than 1 you are trying to take the LOG() of a negative number.
Sorry, I should have given you the entire code. It is attached now.
After mocking up your source table OUT3 looking into your code and running it shows two issues.
data out3;
set sashelp.heart;
mrw_group=ceil(mrw/10);
height_group=ceil(height/5);
weight_group=ceil(weight/10);
run;
proc means data=out3 nway;
class mrw_group;
var mrw;
output out=Out4a Mean=CHD_Mean mean(mrw)=MRW_Mean;
run;
proc means data=out3 nway;
class height_group;
var height;
output out=Out4b Mean=CHD_Mean mean(height)=height_Mean;
run;
proc means data=out3 nway;
class weight_group;
var weight;
output out=Out4c Mean=CHD_Mean mean(weight)=weight_Mean;
run;
data out5a;
set out4a;
Logit_Dia = log( CHD_Mean / (1 - CHD_Mean) );
run;
data out5b;
set out4b;
Logit_Dia = log( CHD_Mean / (1 - CHD_Mean) );
run;
data out5c;
set out4c;
Logit_Dia = log( CHD_Mean / (1 - CHD_Mean) );
run;
Issue 1
It appears that after copy/paste of your data steps you missed to also change the variable names so they match the ones in the input table from the set statement.
Issue 2
If you look into the SAS log you will see: NOTE: Invalid argument to function LOG(-1.015151515) at line
Your expression creates a negative value which is not suitable for the log() function.
Sorry, I should have included the entire code.
We don't have access to your library libname heartlib "/home/u63742108/heartlib"; and the table in there is already a modified version of sashelp.heart
Anyway: I believe the issues identified are what you need to address. Run your code step by step, check the SAS log for any issues and fix the step until working properly before you test the next one.
What's also sometimes worth doing: Disconnect/reconnect to your SAS server so that a new SAS workspace session gets created and not some "leftover" from an earlier run in the same session impacts your current run.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.