Help using Base SAS procedures

How to create "total" text in the column case_opened_month using proc report procedure

Reply
Contributor
Posts: 25

How to create "total" text in the column case_opened_month using proc report procedure

Hi ,

 

I ran the below report procedure for generating SAS report (please see the attachment for output sas report).

 

My question is how to create "Total" text ("total" text  should be 2nd row first column case_opened_month("Month" in the report) 

 

proc report data= days_opened7 ;
columns case_opened_month no_of_cases_closed avg_days_opened ('_Type of Cases_' SURS MCO UTI UNL LOCK );
define case_opened_month /group "Month";
define no_of_cases_closed/analysis sum "No of Cases Closed";
define avg_days_opened / mean "Average days opened";
define SURS /analysis sum "Beneficiary Case: SURS Comprehensive";
define MCO/analysis sum "Beneficiary Case: MCO Education Accuracy";
define UTI/analysis sum "Beneficiary Incident: Utilization";
define UNL/analysis sum "Beneficiary Incident: Unlisted Death Date";
define LOCK/analysis sum "Beneficiary Incident: Lock-In";
rbreak after/summarize ol ul ;
run; 

Super User
Posts: 6,936

Re: How to create "total" text in the column case_opened_month using proc report procedure

Look at page 14 in this document: http://www.excursive.net/sas/ProcReportPaper.pdf

You use a COMPUTE block to set custom text in summary lines, and the automatic variable _break_ to determine in which grouping level you are.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 25

Re: How to create "total" text in the column case_opened_month using proc report procedure

I have used below code in compute block but it is over replaced the column "Month" ( report output ).Feb17 will be replaced with total. Please let me know is there any other way to write the code.

compute case_opened_month/char;
case_opened_month="Total";
endcomp;
Super User
Posts: 6,936

Re: How to create "total" text in the column case_opened_month using proc report procedure

Please read the documents as advised. This is the original example:

compute country;
  if _break_ = 'COUNTRY' then
    country = 'Subtotal';
  else if _break_ = '_RBREAK_' then
    country = 'GrandTotal';
endcomp;

Now compare this with your code, and you'll see what is missing.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 9,676

Re: How to create "total" text in the column case_opened_month using proc report procedure

Better post the example data and output you want see.
That is the best way to describe your question.


 
proc report data= days_opened7 ;
columns case_opened_month no_of_cases_closed avg_days_opened ('_Type of Cases_' SURS MCO UTI UNL LOCK );
define case_opened_month /group "Month";
define no_of_cases_closed/analysis sum "No of Cases Closed";
define avg_days_opened / mean "Average days opened";
define SURS /analysis sum "Beneficiary Case: SURS Comprehensive";
define MCO/analysis sum "Beneficiary Case: MCO Education Accuracy";
define UTI/analysis sum "Beneficiary Incident: Utilization";
define UNL/analysis sum "Beneficiary Incident: Unlisted Death Date";
define LOCK/analysis sum "Beneficiary Incident: Lock-In";


compute after case_opened_month;
 case_opened_month='Total';
endcomp;


rbreak after/summarize ol ul ;
run; 




Contributor
Posts: 25

Re: How to create "total" text in the column case_opened_month using proc report procedure

Hi ,

 

Please see the attachment for input and output of the report.Below is the SAS code.I tried to print the "Total" text in the summary row but I couldn't.

 

proc report data= days_opened7 ;
/*WHERE (DATEPART(valid_from_dttm) GE "&OPEN_DATE_MIN"d) and (DATEPART(valid_from_dttm) LE "&OPEN_DATE_MAX"d);*/
columns case_opened_month no_of_cases_closed avg_days_opened ('_Type of Cases_' SURS MCO UTI UNL LOCK );
define case_opened_month /group "Month";
define no_of_cases_closed/analysis sum "No of Cases Closed";
define avg_days_opened /mean "Average days opened";
define SURS/analysis sum "Beneficiary Case: SURS Comprehensive";
define MCO/analysis sum "Beneficiary Case: MCO Education Accuracy";
define UTI/analysis sum "Beneficiary Incident: Utilization";
define UNL/analysis sum "Beneficiary Incident: Unlisted Death Date";
define LOCK/analysis sum "Beneficiary Incident: Lock-In";

compute case_opened_month;
if _break_='case_opened_month' then case_opened_month='Total';
endcomp;

rbreak after/summarize ol ul ;

run;

Super User
Posts: 9,676

Re: How to create "total" text in the column case_opened_month using proc report procedure

Post the data or photo here, not Excel or Doc file. I wouldn't like to download it due to implying risk.

Contributor
Posts: 25

Re: How to create "total" text in the column case_opened_month using proc report procedure

I solved the issue.Below is the code.


compute case_opened_month;
IF _break_='_RBREAK_' THEN CALL DEFINE('case_opened_month','style','style=[pretext="Total"]');
endcomp;

Ask a Question
Discussion stats
  • 7 replies
  • 149 views
  • 0 likes
  • 3 in conversation