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.
Related
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;
I'm generating tables with rolling weeks of data, so my columns have to be named in the yyyymmdd format like 20161107. I need to apply a comma format to these columns to display counts, but the format is also being applied to the column name so 20161107 turns into 20,161,107. Below is example code that shows the error:
data fish; set sashelp.fish;
TEST = WIDTH*1000;
run;
ods tagsets.excelxp file = "C:\User\Desktop\test.xls" style=minimal
options(embedded_titles="yes" autofit_height="yes" autofilter="all");
proc report data = fish spanrows nowd &header_style.;
column SPECIES TEST;
define SPECIES / display;
define TEST / display "20161107"
f=comma12. style={tagattr='format:###,###,###'}; /* ERROR OCCURS WITH THIS STYLE */
title1 bold "sashelp.fish title";
run; title1;
ods tagsets.excelxp close;
It looks like I can fix this error by padding the display name with spaces like " 20161107 " but I'm not hardcoding these names, so I'd like to try to fix it in the proc report syntax first if possible. Any insight?
You should tell SAS to only apply that style to the column, then:
define TEST / display "20161107"
f=comma12. style(column)={tagattr='format:###,###,###'};
Then it should work as you expect.
Styles in PROC REPORT typically have multiple things they can apply to, and if you don't specify which they apply to all. style(header), style(report), etc. are all options - you can see the full list, plus a good explanation, in the SAS paper Using Style Elements in the REPORT and TABULATE procedures.
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;
I'm trying to create an output for a requestor that wants me to take a preexisting report that comes in two columns on a single page and break it apart on that single page into different subsections, which they want indicated by a new title in the middle of the page where the new subsection begins.
What I have right now is:
ods pdf file=_pdf_ newfile=none startpage=no columns=2 notoc contents=no
style=swsp;
ods text = 'EMPLOYER RENEWAL DATA';
proc report data=renewal_data;
...
run;
ods startpage=now;
ods text='FINANCIAL DATA (FULL PROGRAM YEAR)';
proc report data=financial_data_total;
...
run;
ods startpage=now;
title1 '$ACA_YR_STR. ACADEMIC YEAR DATA';
footnote;
ods text='APPLICANT DATA';
...
run;
What I want is the page to have a section title where the second ods startpage=now is located that treats the entire page as one column, but then returns to two columns for the remainder of the page.
Thanks!
If you have SAS 9.4 (and possibly 9.3), you can use ODS LAYOUT to achieve this pretty easily. You need to create a gridded layout, and then change your title to another ODS TEXT (which you can of course style to be like a title). Titles go with PROCs, not by themselves, so if you actually use title it will appear where the next PROC REPORT goes, not in its own area.
Here's a barebones example that might get you started. See the ODS REGION and ODS LAYOUT documentation for more information. Note, this is something that is in production, but is also in active development, so different versions of SAS (including newer ones) may change how some of this works (though hopefully not break formerly existing functionality, who knows).
ods pdf file="c:\temp\test.pdf" startpage=no newfile=none notoc contents=no
style=swsp;
options obs=10;
ods layout gridded columns=2 rows=3;
ods region row=1 column=1;
ods text = 'CLASS DATA';
proc report data=sashelp.class;
columns name age;
run;
ods region row=1 column=2;
ods text='CAR DATA';
proc report data=sashelp.cars;
columns make model;
run;
ods region column_span=2 row=2 column=1;
ods text='ACROSS THE WHOLE PAGE NOW';
footnote;
ods region row=3 column=1;
ods text='NOT ACROSS WHOLE PAGE FOR THIS PART';
proc report data=sashelp.baseball;
columns name team;
run;
ods layout end;
ods pdf close;
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