@BrunoMueller I see you are getting different output than mine. This is kind of weird. There must be something preventing in my output not writing region tile 1 and tile 2. Please see screen capture of output and log file.
@BrunoMueller Update: When I removed "gridded" ODS layout then the output is similar to yours except it removed header title "Counts by Region". May be gridded option not available in my sas environment. Otherwise I am close to the solution.
@BrunoMueller Few thinks to nailed it down, what could be the region it is not working with 'gridded' layout in my condition? when I remove gridded then it will show region titl1 and 2 but when I aply ODS PDF option, it again removes region titl1 and 2 . I want these graphs (13 regions) to output into a single page to accomplish my organization's goal.
Let me known if you shed some lights here.
From the log one can see, that you are using the SAS Report ODS destination. This one does not support gridded layout.
I made some changes to the code:
Here is the code:
Data want;
length Region trend $ 16;
call streaminit(1234);
do n = 1 to 13;
region = cats("Region", put(n, z2.));
trend = choosec(rand("integer",1, 3), "Increasing", "Decreasing", "Neutral");
do repDate = 1 to 7;
cnt_11fnc = rand("integer", 1, 16);
avg_11fnc = rand("uniform") * 8;
output;
end;
end;
format
repdate 2.
cnt_11fnc 3.
avg_11fnc 4.1
;
run;
%macro plots;
%local i nObs region trend;
proc sql noprint;
select distinct
region
, trend
into
:regionValue1 -
, :trendValue1 -
from
want
;
%let nObs = &sqlobs;
quit;
%do i = 1 %to &nObs;
%let region = &®ionValue&i;
%let trend = &&trendValue&i;
%put NOTE: &sysmacroname processing &i of &nobs &=region &=trend;
ods region;
/* title1 "®ion";*/
%if &trend = Decreasing %then
%do;
title1 "®ion" c=red "&trend^{unicode '2198'x}";
%end;
%if &trend = Increasing %then
%do;
title1 "®ion" c=blue "&trend^{unicode '2197'x}";
%end;
%if &trend = Neutral %then
%do;
title1 "®ion" c=black "&trend^{unicode '2192'x}";
%end;
proc sgplot data=Want noautolegend;
where region = "®ion";
vbar RepDate / response=cnt_11FNC;
vline RepDate / response=avg_11FNC;
run;
%end;
ods layout end;
title;
%mend;
ods _all_ close;
ods escapechar="^";
options orientation=landscape papersize="A3" ;
ods pdf file="c:\temp\report.pdf" nogtitle;
title "Counts by Region";
ods graphics / width=72mm height=65mm;
ods layout gridded columns=5 column_gutter=5mm;
%plots
ods pdf close;
Hi @BrunoMueller your revised code did help in this process. There was one code I absolutely needed which I found in sas communities i.e. ODS tagsets.sasreport13(ID=EGSR) gtitle; otherwise writing region title with unicode was not possible. I played around little bit and connected with my data. I think it is pretty good now. Thank you. Thank you to @Rick_SAS who showed me the concept of putting unicode character. Appreciated @ballardw for wiliness to help.
BTW, is there a way to write some text, note in the area circled red, see screenshot attached. My codes are here (I did not use "Data want.... steps as I got an error of "NOTE: Argument 1 to function RAND at line 21 column 21 is invalid." for trend = choosec(rand("integer",1, 3), "Increasing", "Decreasing", "Neutral"); SO I linked data directly with my other file.
I tried writing ods text or proc odstext but text goes either in the second page, but I wanted to write note in the res circle area, if pssible.
/*options nodate nonumber center;*/
ODS PDF CLOSE;
%macro plots;
%local i nObs region trend;
proc sql noprint;
select distinct
region
, trend
into
:regionValue1 -
, :trendValue1 -
from
want
;
%let nObs = &sqlobs;
quit;
%do i = 1 %to &nObs;
%let region = &®ionValue&i;
%let trend = &&trendValue&i;
%put NOTE: &sysmacroname processing &i of &nobs &=region &=trend;
ods region;
/* title1 "®ion";*/
%if &trend = Decreasing %then
%do;
title1 justify=left HEIGHT=14pt FONT='Arial' color=dabgr bold "®ion - " c=red "&trend^{unicode '2198'x}";
%end;
%if &trend = Increasing %then
%do;
title1 justify=left HEIGHT=14pt FONT='Arial' color=dabgr bold "®ion - " c=blue "&trend^{unicode '2197'x}";
%end;
%if &trend = Neutral %then
%do;
title1 justify=left HEIGHT=14pt FONT='Arial' color=dabgr bold "®ion - " c=black "&trend^{unicode '2192'x}";
%end;
proc sgplot data=Want noautolegend;
where region = "®ion";
vbar RepDate / response=cnt_11FNC nooutline dataskin=none fillattrs=( color=lightgrey);
vline RepDate / response=avg_11FNC lineattrs=(color=red thickness=2 PATTERN=SHORTDASH);
run;
%end;
ods layout end;
%mend;
ods _all_ close;
ods escapechar="^";
options orientation=landscape papersize="A3" nodate;
ods pdf file="/SAS_data/research/CD_Epis/Bijay/COVID19/dailyreport/archive/dashboard7.pdf" ;
title justify=center HEIGHT=22pt FONT='Times New Roman' color=big bold "Dashboard for the Past 14 days Trend";
title2 justify=center HEIGHT=12pt FONT='Arial' color=dabgr bold "Daily new cases over the past 14 days: &sysdate9" ;
ods graphics /noborder width=72mm height=65mm;
ods layout gridded columns=5 column_gutter=5mm row_gutter=50;
options leftmargin=.01in rightmargin=.01in topmargin=1in bottommargin=.01in;
ODS tagsets.sasreport13(ID=EGSR) gtitle;
%plots
title;
ods pdf close;
included all except
A note: since you only want to have the PDF output, I would switch off any automatic output generation for the program in Enterprise Guide, you can do this on the properties of the program. Yes GTITLE/GFOOTNOTE control whether title/footnotes are placed inside a graph or outside.
There are ways to write into the space you market in the screenshot.
For instance there is the COLUMN_SPAN= option for the ODS REGION statement that allows you to place some text over two columns.
Find below a code sample to get you started:
/*
* create some text data
*/
data loremipsum;
length someText $ 2048;
infile cards;
input;
if substr(_infile_,1, 3) = "EOD" then do;
output;
end;
retain someText;
someText = catx(" ", someText, _infile_);
cards;
suscipit tellus mauris a diam maecenas sed enim ut sem viverra aliquet eget sit amet tellus
cras adipiscing enim eu turpis egestas pretium aenean pharetra magna ac placerat vestibulum
lectus mauris ultrices eros in cursus turpis massa tincidunt dui ut ornare lectus sit amet est
placerat in egestas erat imperdiet sed euismod nisi porta lorem mollis aliquam ut porttitor leo
a diam sollicitudin tempor id eu nisl nunc mi ipsum faucibus vitae aliquet nec ullamcorper
EOD
;;;;
/*
* macro to print some graphs
*/
%macro somePlots(n=4);
%local i randomColor hlsPastelRandom;
%do i = 1 %to &n;
%let hlsPastelRandom = %hlsPastelRandom;
ods region style={background=&hlsPastelRandom};
title "color=&hlsPastelRandom";
Proc sgplot data=sashelp.cars noopaque;
vbar type;
run;
title;
%end;
/*ods layout end;*/
%mend;
/*
* generate some random pastel color
*/
%COLORMAC
%macro hlsPastelRandom;
%local h s l;
%let h = %sysevalf(360 * %sysfunc(rand(uniform)), integer);
%let s = %sysevalf(25 + (70 *%sysfunc(rand(uniform))), integer);
%let l = %sysevalf(85 + (10 *%sysfunc(rand(uniform))), integer);
%hls(&h, &l, &s)
%mend;
%put *%hlsPastelRandom*;
ods _all_ close;
options
orientation=landscape
papersize="A4"
;
ods graphics / reset=all;
ods pdf file="c:\temp\someplots.pdf" nogtitle;
ods layout gridded columns=3 rows=2 row_heights=(9cm 9cm) column_widths=(9cm 9cm 9cm);
%somePlots(n=4)
options nocenter;
ods region column_span=2 style={background=%hlsPastelRandom};;
proc odstext data=loremipsum;
p "title for text box" / style=systemtitle;
p someText / style={width=18cm font_size=12pt};
run;
ods layout end;
ods pdf close;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.