Create a Detail Report by Proc Report - sas

I am trying to create a Detail Report by Proc Report. I wrote this code:
ods pdf file = "D:\New folder (2)\Assignment\Case_Study_1\Detail_Report.pdf";
proc report data = Cs1.Detailed_Report headline;
Title 'Olympic Pipeline (LONDON) - by Probability As of 17th November 2012';
column Probability Account_Name Opportunity_Owner Last_Modified_Date Total_Media_Value Digital_Total_Media_Value Deal_Comments;
where Probability > 0;
define Probability/group Descending 'Probability';
define Account_Name/across 'Client';
define Opportunity_Owner/across 'Champ';
define Last_Modified_Date/across format = MMDDYY. 'Modified';
define Total_Media_Value/across format = dollar25. 'Tot_Budget';
define Digital_Total_Media_Value/across format = dollar25. 'Digital_Bugt';
define Deal_Comments/across 'Deal_Comments' width = 150;
rbreak after / summarize ol ul;
run;
ods listing close;
ods pdf close;
After running this code log shows an error that
The width of Deal_Comments is not Between 1 to 121. Adjust the column
width. Page size is too small for Column Titles.
Can you please suggest a solution to this problem. Thanks in advance.

More than likely you have the ODS LISTING destination open and the error is related to that destination. You can either modify the ls option for the destination or you can turn it off.
ODS LISTING CLOSE;
...your sas code
ODS LISTING;

Related

PROC REPORT WITH MACRO

I would like to create MACRO to produce a report (proc report) for each of datasets. For each report include title, "CYBOCS Compulsion Scale:Q6_#". Bold the line that has cycle 12 in it as cycle 12 is the primary endpoint. And using ODS RTF to output all reports to the personal drive
Here is the table look like:
Here is my code, I don't sure how to add bold line and how should I use ODS RTF to export reports
ODS RTF
%MACRO diff(var=);
PROC REPORT DATA=table_&var.;
TITLE "CYBOCS COMPULSION SCALE: &var";
RUN;
%MEND diff;
options mprint mlogic;
%diff(var=q6_1a);
%diff(var=q6_1b);
%diff(var=q6_2);
%diff(var=q6_3);
%diff(var=q6_4);
%diff(var=q6_5);
%diff(var=q6_6);
%diff(var=q6_7);
%diff(var=q6_date);
Use a compute block and add your condition. You can use call define() to conditionally change a style based on your logic. For example, if we wanted to bold the row for every BMW in sashelp.cars:
proc report data=sashelp.cars;
compute Make;
if(Make = 'BMW') then call define(_ROW_, 'style', 'style=[font_weight=bold]');
endcomp;
run;

Output distribution charts in a pdf format? I only need the chart from a proc univariate of all the variables in a table

How can I output distribution charts in a pdf format? I only need the chart from a proc univariate of all the variables in a table - not any additional metrics.
ods pdf file="aaaa.pdf
TITLE 'Summary of Weight Variable (in pounds)';
PROC UNIVARIATE DATA = sashelp.class NOPRINT;
HISTOGRAM _all_ / NORMAL;
RUN;
ods pdf close
You use ODS SELECT _chartname_ to limit the output to what you want. You need to remove the NOPRINT option though or no output is generated to display regardless of destination.
It looks like univariate produces: CDFPlot, Histogram, PPplot, Probplot, QQplot so assuming you want just the histogram add the following line to your code:
ods select histogram;
Full code:
ods pdf file="aaaa.pdf;
ods select histogram;
TITLE 'Summary of Weight Variable (in pounds)';
PROC UNIVARIATE DATA = sashelp.class ;
HISTOGRAM _all_ / NORMAL;
RUN;
ods pdf close
Add it before or within your PROC UNIVARIATE.
PS. You're missing a semicolon on your ODS PDF statements at the top and bottom.
A good blog post from the SAS website on this is available here.

ODS Excel / Proc Report - no wordwrap / merged cells?

I use SAS ODS a lot to export prettied up excel files. One in particular has titles that go significantly longer than the width of all of the columns, so they word wrap, which makes the file look horrible.
Is there any way to export a file with word wrap turned off? I've searched on the SAS support forums, and have found very little helpful information.
%let myfile = "C:\Users\dicegods\testfile.xlsx";
ods excel file=&myfile. options (orientation='portrait' sheet_name='Baseball' embedded_titles='yes');
options LeftMargin=0.25in RightMargin=0.25in TopMargin=0.25in BottomMargin=0.25in;
proc report data=sashelp.baseball;
column name nHome nHits;
define name / display 'Name';
define nHome / display 'Homers' sum;
define nHits / analysis 'Hits' sum;
title; title1 J=L "Baseball Players from SAS Help Database - sashelp library inEG - more run on stuff";
run;
Try using ODS TEXT. The following code snippet shows a simple way to use ODS TEXT to insert a "title" into the top of the sheet being generated by the following PROC step. Look up the documentation on ODS TEXT to see how to control the formatting of the generated text
%let myfile = "C:\downloads\testfile.xlsx";
ods excel file=&myfile. options (orientation='portrait' sheet_name='Baseball' embedded_titles='no');
ods text="Baseball Players from SAS Help Database - sashelp library inEG - more run on stuff";
options LeftMargin=0.25in RightMargin=0.25in TopMargin=0.25in BottomMargin=0.25in;
proc report data=sashelp.baseball;
column name nHome nHits;
define name / display 'Name';
define nHome / display 'Homers' sum;
define nHits / analysis 'Hits' sum;
title J=L "Baseball Players from SAS Help Database - sashelp library inEG - more run on stuff";
run;
title;
ods excel close;
I think you need this option, FLOW, as shown in the image below.

Break After & R Break

I am creating a report using proc report. My syntax runs fine but it doesnot shows the results of R break & After break in the output report. Thanks in advance
ods pdf file = "D:\New folder (2)\Assignment\Case_Study_1\Detail_Report.pdf";
proc report data = Cs1.Detailed_Report headline nowd ls = 256 ps = 765;
Title 'Olympic Pipeline (LONDON) - by Probability As of 17th November 2012';
column Probability Account_Name Opportunity_Owner Last_Modified_Date Total_Media_Value Digital_Total_Media_Value Deal_Comments;
where Probability > 0;
define Probability/group Descending 'Probability';
define Account_Name/order 'Client';
define Opportunity_Owner/order 'Champ';
define Last_Modified_Date/order format = MMDDYY. 'Modified';
define Total_Media_Value/order format = dollar25. 'Tot_Budget';
define Digital_Total_Media_Value/order format = dollar25. 'Digital_Bugt';
define Deal_Comments/order 'Deal_Comments';
break after Probability/ summarize suppress ol ul;
rbreak after / summarize ol ul;
run;
ods listing close;
ods pdf close;
Your main problem is that you don't have anything for the summarization to do. All of your columns are "ORDER" columns, which is probably not what you want. This is a common confusion in PROC REPORT; ORDER actually can be used in two different ways.
ORDER column type (vs. ANALYSIS, GROUP, ACROSS, COMPUTED, etc.)
ORDER= instruction for how to order data in a column (ORDER=DATA, ORDER=FORMATTED, etc.)
You can instruct SAS how to order a column without having to make it an ORDER column (which is basically similar to GROUP except it doesn't condense extra copies of a value if there are more than one).
If you want RBREAK or BREAK to do anything, you need to have an ANALYSIS variable(s); those are the variables that you want summaries (and other math) to work on.
Here is an example of this working correctly, with analysis variables. You need to tell SAS what to do, also, when summarizing them; mean, sum, etc., depending on what your desired result is.
ods pdf file = "c:\temp\test.pdf";
proc report data = sashelp.cars headline nowd ls = 256 ps = 765;
column cylinders make model invoice mpg_highway mpg_city;
where cylinders > 6;
define cylinders/group Descending;
define make/order;
define model/order;
define invoice/analysis sum;
define mpg_highway/analysis mean;
define mpg_city/analysis mean;
break after cylinders/ summarize suppress ol ul;
rbreak after / summarize ol ul;
run;
ods pdf close;

SAS Ods RTF and PROC REPORT

So I've writen this:
ods rtf file = "D:\Sarath\List\2.rtf";
proc report data = list.lst1;
column PATIENT EOSDT STDRUG STDRUGSP STDCOMP STDCOMSP DAY5 EOSREAS;
define PATIENT/display "Subject * Number";
define EOSDT /order "Date of * Study Completion/ * Early Discontinuation";
define STDRUG/order "Administered*Study Drug?";
define STDRUGSP/display "If no,*Specify" ;
define STDCOMP/order "Completed*Dosing";
define STDCOMSP/display "If no,*Specify";
define DAY5/order "Completed*Study?";
define EOSREAS/display "Reason for * not Completing";
run;
ods rtf close;
and it creates an rtf with no data. Just a blank page. Please tell me what am I doing wrong here.
Regards.
Add nowd to the proc report line, otherwise SAS is expecting proc report to be an interactive procedure.
proc report data = list.lst1 nowd;
See documentation here:
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473620.htm