SAS PROC TEMPLATE TEXT BREAK LINES - sas

My aim is to generate an fdf output due to SAS so I can import it into adobe.
Unfortunately, my proc template produced file "template.fdf" is just single row. However, I need a new line of code after every put statement. Is there a way to insert this?
Thank you in advance
PROC TEMPLATE;
DEFINE TAGSET template.FDF / STORE = SASUSER.TEMPLAT;
DEFINE EVENT DOC_BODY;
START:
put "%FDF-1.2 "; <=== new breakline in the document
PUT "text"; <=== new breakline in the document
put "<</Root 1 0 R>> ";<=== new breakline in the document
FINISH:
PUT "%%EOF";
END;END;
RUN;
FILENAME OUT "C:\..\template.FDF";
ODS LISTING CLOSE;
ODS MARKUP BODY = OUT
TAGSET = template.FDF;
ODS MARKUP CLOSE; ODS LISTING;

NL option on PUT statement
put "%FDF-1.2 " nl;
From example 3
TEMPLATE Procedure: Creating Markup Language Tagsets

Related

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.

How to append multiple ODS html exports into single HTML file?

I'm exporting multiple datasets using ODS html (example below).
It saves HTML files on the server and in order to attach them to email.
The code is used to export looks like this:
ods html file="/user_data/maexport/generated_html.html";
proc print data=WORK.DATA_SET_0001;
run;
ods html close;
Now how can I append these multiple proc printed HTMLs into single HTML file?
Put all your prints before your ODS close statement.

Including syntax in SAS ODS pdf file

Is it possible to include submitted syntax or even output of log file when ODS into a PDF using SAS?
For instance, give this simple code:
ods pdf file = "c:\temp\myPDF.pdf";
proc reg data = mydata;
model y = x;
run;
ods pdf close;
I can get the regression output and accompanying graph fine. But is it possible to incorporate into PDF the enclosed command like this?
proc reg data = mydata;
model y = x;
run;
It is, but it requires a couple of hoops. Luckily, you could wrap this into macros to clean up your code.
Create a temporary fileref to hold your log.
Start your PDF and output the log to the fileref.
Write code.
Stop writing log to fileref.
Print file contents to PDF using ODF TEXT=
Hope this helps
filename x temp;
ods pdf file="c:\temp\temp.pdf";
title "Cost of Power";
options source;
proc printto log=x;
run;
proc reg data=sashelp.cars;
model msrp = horsepower;
run;
quit;
proc printto;run;
title;
ods pdf startpage=now; /*Force a new page in the PDF*/
data _null_;
infile x;
input;
call execute("ods text='LOG: "||_infile_||"';");
run;
ods pdf close;
filename x ;

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

How do I insert vertical space into a PDF document using ODS PDF?

I'm using ODS PDF to create a simple PDF report, but I'm having trouble inserting space between the tables into the PDF file. This is the code so far:
ODS PDF FILE = "test.pdf" STARTPAGE = NEVER;
DATA CLINIC;
INPUT ID $ 1-3
GENDER $ 4
RACE $ 5
HR 6-8
SBP 9-11
DBP 12-14
N_PROC 15-16;
AVE_BP = DBP + (SBP - DBP)/3;
DATALINES;
001MW08013008010
002FW08811007205
003MB05018810002
004FB 10806801
005MW06812208204
006FB101 07404
007FW07810406603
008MW04811207006
009FB07719011009
010FB06616410610
;
ODS PDF TEXT = "MEANS PROCEDURE FOR EVERYONE";
PROC MEANS DATA=CLINIC N STD MEAN;
VAR SBP DBP;
RUN;
ODS PDF TEXT = "TEXT FOR ANALYSIS GOES HERE";
* Vertical space should be inserted here;
ODS PDF TEXT = "MEANS PROCEDURE FOR MEN ONLY";
PROC MEANS DATA=CLINIC N STD MEAN;
WHERE GENDER = "M";
VAR SBP DBP;
RUN;
ODS PDF TEXT = "TEXT FOR ANALYSIS GOES HERE";
ODS PDF CLOSE;
I know that if I remove STARTPAGE = NEVER; the tables will appear on separate pages, but since these are short tables, it doesn't make sense to have each small table on a separate page.
I'm just trying to insert some vertical space into the file where the comments indicate (between the text after the first table and the text before the first table). How can I do this?
You could just add some newlines like:
ods pdf text="^{newline 1}";
The 1 can be replaced with how many lines of white space you want added.
This is assuming your escape character is the same as mine. If not, set it like:
ods escapechar="^";