Hi Team,
In the following report I am basically trying to get the overall line at the bottom and the subtotals . I get an error:
ERROR: The variable type of READMIT_DENOM.SUM is invalid in this context.
NOTE: The preceding messages refer to the COMPUTE block for Readmit.
ERROR: The variable type of READMIT_RATE_DENOM_CASES.SUM is invalid in this context.
Could you please help me figure out why the error?
Regards
proc report data=both_2 style(report)={outputwidth=10in} style(column)=[bordercolor=maroon]
nowindows HEADLINE spacing=1 missing headskip split="|";
columns Category drg DRGDESC
('TEMP' count LOS_System Readmit_Numer Readmit_Denom=Readmit_Denom_TEMP totpercentA Readmit)
('BENCHMARK' Cases Mean_LOS__Obs_ _0_Day_Readmit_Cases Readmit_Rate_Denom_Cases=Readmit_Rate_Denom_Cases_BM totpercentB Readmit_BM);
define Category/group style=[font_weight=bold font_style=italic font_size=9pt];
define drg /group left width=23 "DRG TRIPLETS";
define DRGDESC/group "DRG Description";
define count/analysis;
define LOS_System/mean;
define Readmit_Numer/sum center 'Readmit Numerator' ;
define Readmit_Denom/ sum center 'TDenom';
define Readmit_Denom_TEMP/analysis noprint;
define totpercentA/computed '%TotalTEMP' format=percent9.2;
define Readmit/f=percent9.2 'TEMP_Rate'; /*this rate variable was created with a out=option of previous proc report*/
define Cases/analysis;
define Mean_LOS__Obs_/mean;
define _0_Day_Readmit_Cases/sum;
define Readmit_Rate_Denom_Cases/analysis 'BM Den';
define Readmit_Rate_Denom_Cases_BM/analysis noprint;
define totpercentB/computed '%TotalBM'format=percent9.2;
define Readmit_BM/f=percent9.2 'BMRate'; /*this rate variable was also created with a out=option of previous proc report*/
compute before;
totcountA=Readmit_Denom_TEMP;
totcountB=Readmit_Rate_Denom_Cases_BM;
endcomp;
compute before Category;
count_T=Readmit_Denom_TEMP;
Count_BM=Readmit_Rate_Denom_Cases_BM;
endcomp;
compute readmit;
if _break_ = '_RBREAK_' then do;
Readmit.sum = Readmit_Numer.sum / Readmit_Denom.sum;
endcomp;
compute totpercentA;
totpercentA=Readmit_Denom_TEMP/totcountA;
endcomp;
compute totpercentB;
totpercentB=Readmit_Rate_Denom_Cases_BM/totcountB;
endcomp;
compute Readmit_BM;
if _break_ = '_RBREAK_' then do;
Readmit_BM.sum= _0_Day_Readmit_Cases.sum/Readmit_Rate_Denom_Cases.sum;
end;
endcomp;
break after Category /summarize skip ol style=[font_weight=bold font_style=italic font_size=9pt];
rbreak after / summarize dul style =[font_weight=bold font_style=italic font_size=9pt];
compute after Category;
line '';
endcomp;
compute Category;
if _break_ = 'Category'
then do Category = 'Subtotal';
call define (_row_,'style',"style={font_weight=bold font_size=9pt background=honeydew}");
end;
else if _break_ = '_RBREAK_'
then do Category = 'TOTAL';
call define (_row_,'style',"style={font_weight=bold font_size=9pt background=aliceblue}");
end;
endcomp;
run;
ods pdf close;
Hi:
Without seeing your data, it is really hard to evaluate all your code. But you are missing an END statement in your COMPUTE block for READMIT. (you have a test for _RBREAK_, but no END.)
Then, I see that you have several aliases. When you alias a variable in the COLUMN statement, you do NOT use the compound name in a COMPUTE block. You use the ALIAS and only the ALIAS. So in the screenshot of my SAS Log, I used code with this COLUMN statement:
column name age sex height=ht weight diff;
As the log shows, in a COMPUTE block, using HEIGHT.SUM would be incorrect, because the alias tells PROC REPORT that you will always refer to the aliassed item as HT. Then, it would ALSO be incorrect to use HT.SUM because HT is NOT an analysis item with the usage of SUM. The USAGE is COMPUTED and so HT would only be referred to as HT in a COMPUTE block.
You might be better off working with Tech Support, where they can look at all your data and all your code to help you figure out what's wrong with the code and/or your logic.
cynthia
Hi:
Without seeing your data, it is really hard to evaluate all your code. But you are missing an END statement in your COMPUTE block for READMIT. (you have a test for _RBREAK_, but no END.)
Then, I see that you have several aliases. When you alias a variable in the COLUMN statement, you do NOT use the compound name in a COMPUTE block. You use the ALIAS and only the ALIAS. So in the screenshot of my SAS Log, I used code with this COLUMN statement:
column name age sex height=ht weight diff;
As the log shows, in a COMPUTE block, using HEIGHT.SUM would be incorrect, because the alias tells PROC REPORT that you will always refer to the aliassed item as HT. Then, it would ALSO be incorrect to use HT.SUM because HT is NOT an analysis item with the usage of SUM. The USAGE is COMPUTED and so HT would only be referred to as HT in a COMPUTE block.
You might be better off working with Tech Support, where they can look at all your data and all your code to help you figure out what's wrong with the code and/or your logic.
cynthia
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.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.