The SAS Output Delivery System and reporting techniques

Titles are not resolving in ODS PDF OUTPUT

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 110
Accepted Solution

Titles are not resolving in ODS PDF OUTPUT

Hi SAS experts,

am creating a macro "print" which is printing all the names in the dataset sashelp.class with titles.

But when am doing this in the ods pdf am not getting the titles for all the names, instead am getting the titles only for the first name.

Below is my code..please guide

 

 

step1--

%macro print;


proc sql noprint;
select count(distinct name) into:ct1 from sashelp.class;
quit;;


proc sql noprint;
select distinct name
into :name1-:name%sysfunc(compress(&ct1.))
from sashelp.class;
quit;

%do i=1 %to &ct1.;

title h=2 "each person info &&name&i.";
proc print data=sashelp.class;
where name="&&name&i.";
run;
%end;
%mend;

 

 step2--

%LET folder_path=path;


ods pdf file="path.pdf" startpage=no;

proc means data=sashelp.class;
class sex;
var height;
run;

ods pdf startpage=now;
%include "&folder_path.\print.sas";
%print;
ods pdf close;

 

Thanks & regards,

Sanjay.

 


Accepted Solutions
Solution
‎10-25-2016 06:48 AM
SAS Super FREQ
Posts: 8,720

Re: Titles are not resolving in ODS PDF OUTPUT

Hi, I am not sure what you mean when you say that you want "Ods pdf text will be same per alll the pages but titles will be changed" -- it was my understanding from your original post that you wanted a title above the proc print for each NAME -- that string would become ODS TEXT, as shown here:

use_title_ods_text.png

 

Some variation of that should work for you. But in my example, the TITLE text goes with PROC MEANS, then gets turned off after MEANS and the ODS TEXT takes over (and looks like a TITLE because of the STYLE change) for every PROC PRINT.

 

cynthia

View solution in original post


All Replies
Frequent Contributor
Posts: 110

Tiles are not resolving in ODS PDF OUTPUT

Hi SAS experts,

am creating a macro "print" which is printing all the names in the dataset sashelp.class with titles.

But when am doing this in the ods pdf am not getting the titles for all the names, instead am getting the titles only for the first name.

Below is my code..please guide

 

 

step1--

%macro print;


proc sql noprint;
select count(distinct name) into:ct1 from sashelp.class;
quit;;


proc sql noprint;
select distinct name
into :name1-:name%sysfunc(compress(&ct1.))
from sashelp.class;
quit;

%do i=1 %to &ct1.;

title h=2 "each person info &&name&i.";
proc print data=sashelp.class;
where name="&&name&i.";
run;
%end;
%mend;

 

 step2--

%LET folder_path=path;


ods pdf file="path.pdf" startpage=no;

proc means data=sashelp.class;
class sex;
var height;
run;

ods pdf startpage=now;
%include "&folder_path.\print.sas";
%print;
ods pdf close;

 

Thanks & regards,

Sanjay.

 

 

 

 

 

Esteemed Advisor
Esteemed Advisor
Posts: 7,220

Re: Titles are not resolving in ODS PDF OUTPUT

Errm, not sure why your doing that, simply:

proc print data=sashelp.class;
  by name;
  title "The name is: #byval1";
run;

As always, macro is not a replacement for Base SAS.

SAS Super FREQ
Posts: 8,720

Re: Titles are not resolving in ODS PDF OUTPUT

[ Edited ]

Hi, the other thing that might be causing a problem is your STARTPAGE option (although I agree with RW9 that you could use BY group processing and don't need a macro).

Your STARTPAGE=NOW is issuing 1 page "break" between PROC MEANS and the first PROC PRINT. but then the page breaks will stay off for everything else on the page. So essentially, you will only see a title for the first PROC PRINT that appears at the top of each page (if your output spans multiple pages). Known behavior of STARTPAGE is to suppress the title for every procedure but the first procedure on the page. This is why there is ODS TEXT ... if you really want some title text in between each output.

Or, the other thing you could try is STARTPAGE=YES before your %include and %PRINT macro.

Or here's an alternate BY group approach that shows the BYLINE above each table (not as a TITLE):

options byline;
ods pdf file='c:\temp\byvalprt.pdf' startpage=no;
  proc print data=sashelp.class;
   by name;
   title "Top Title";
  run;
ods pdf close;

bygroup_approach.png
cynthia

Frequent Contributor
Posts: 110

Re: Titles are not resolving in ODS PDF OUTPUT

Hi Cynthia,

 

That really helps me, is there is anyway to use both title and ods pdf text in one page..

Ods pdf text will be same per alll the pages but titles will be changed.

 

Thanks,

Sanjay.

Solution
‎10-25-2016 06:48 AM
SAS Super FREQ
Posts: 8,720

Re: Titles are not resolving in ODS PDF OUTPUT

Hi, I am not sure what you mean when you say that you want "Ods pdf text will be same per alll the pages but titles will be changed" -- it was my understanding from your original post that you wanted a title above the proc print for each NAME -- that string would become ODS TEXT, as shown here:

use_title_ods_text.png

 

Some variation of that should work for you. But in my example, the TITLE text goes with PROC MEANS, then gets turned off after MEANS and the ODS TEXT takes over (and looks like a TITLE because of the STYLE change) for every PROC PRINT.

 

cynthia

Frequent Contributor
Posts: 110

Re: Titles are not resolving in ODS PDF OUTPUT

Thank you very much Cynthia.

Frequent Contributor
Posts: 110

Re: Titles are not resolving in ODS PDF OUTPUT

Hi Cynthia,

Is there is anyway to place the display of numbers right side or the left side of the map. (age 20-20 26-26 28-32 below the map, is there is anyway to palce it right side or left side of the map )

Below is my code

 

data response_data;
input idname$ X Y age;
cards;
Cuba -20722.00205 4678.3461646 20 24
Guatemala -21079.71903 4444.6666525 26
Haiti -20480.41176 4569.4493199 28
Honduras -20942.88097 4419.9807239 32
;
run;

proc template;
define style styles.colorramp;
parent=styles.pearl;
style twocolorramp / startcolor=cxF3F7FE endcolor=cx6497EB;
end;
run;
data anno;
length function style color $ 10 position $ 1 text $5;
retain flag 0 function 'label' xsys ysys '2' hsys '3' when 'a' ;
set response_data ;
color= 'black';
text=put(age,comma5.);
position = '5' ;
size = 2.5;
style = "Cumberland AMT";
output;
run;
proc gmap data=response_data map=mapsgfk.world;
id IDNAME;
choro age/annotate=anno coutline=grayaa xsize = 2 in ysize = 2 in;
run;
quit;

 

Thanks & Regards,

Sanjay

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 525 views
  • 0 likes
  • 3 in conversation