Hello,
I am trying to create a PowerPoint presentation with a custom layout for one of the slides (2 rows, 2 columns).
For the custom layout I have been trying to use ODS Layout Gridded, but have not been able to get it to show up on the slide correctly. It seems that SAS is trying to add the content of the Gridded layout slide to the previous slide.
Any suggestions? Below is a simplified version of the code I am working with, and it has the same effect. I am using SAS EG 6.1.
Thanks,
Craig
proc sql;
create table cars as
select Make,
sum(MSRP) as TotMSRP format=dollar10.
from sashelp.cars
group by Make;
quit;
ods powerpoint file="cars.pptx" layout=_null_;
/*Slide 1 with text in bottom left corner.*/
proc odstext;
p "";
p "";
p "";
p "";
p "";
p "";
p "";
p "";
p "Daily Report" / style={fontweight=bold fontsize=36pt};
p "%sYsFunc(putn(%sYsFunc(today()),WeekDate.))" / style={fontweight=bold fontsize=20pt};
run;
/*Slide 2 with a gridded layout*/
ods layout gridded rows=2 columns=2;
ods graphics / width=8in height=3in;
ods region row=1 column_span=2;
proc sgplot data = cars;
vbar Make / response=TotMSRP
nostatlabel name="bar" nooutline;
yaxis min=0 offsetmin=0 values=(0 to 1650000 by 150000) grid
label="Total MSRP";
xaxis display=(noticks nolabel);
run;
ods region row=2 column=1;
proc odslist;
item;
p "Car Makes" / style={fontweight=bold fontsize=10pt};
list;
item "Acura" / style={fontsize=10pt};
item "Audi" / style={fontsize=10pt};
item "BMW" / style={fontsize=10pt};
item "Buick" / style={fontsize=10pt};
item "ETC" / style={fontsize=10pt};
end;
end;
run;
ods region row=2 column=2;
proc odslist;
item;
p "Car Makes" / style={fontweight=bold fontsize=10pt};
list;
item "Acura" / style={fontsize=10pt};
item "Audi" / style={fontsize=10pt};
item "BMW" / style={fontsize=10pt};
item "Buick" / style={fontsize=10pt};
item "ETC" / style={fontsize=10pt};
end;
end;
run;
ods layout end;
ods powerpoint close;
Thanks for the responses! I checked with tech support and Jane set me along the right path.
This way her reply:
"...It is possible to create the output that you want. There are a couple of things to note.
ODS PowerPoint will not start a second slide until the first one is full. Sometimes this means a graph is placed on the first slide but it is really small. In that circumstance you have to force a new slide with a DATA _NULL_ step -- I have included that step in the attached code.
Another thing is that column_span and row_span do not work as well in PowerPoint as they do in PDF or HTML. Therefore, I recommend that you create a separate layout container for the graph that you want to span two columns..."
Below is the revised code Jane from tech support sent me:
proc sql;
create table cars as
select Make,
sum(MSRP) as TotMSRP format=dollar10.
from sashelp.cars
group by Make;
quit;
ods _all_ close;
title;
ods powerpoint file='test.pptx';
/*Slide 1 with text in bottom left corner.*/
proc odstext;
p "";
p "";
p "";
p "";
p "";
p "";
p "";
p "";
p "Daily Report" / style={fontweight=bold fontsize=36pt};
p "%sYsFunc(putn(%sYsFunc(today()),WeekDate.))" / style={fontweight=bold fontsize=20pt};
run;
/*insert slide break*/
data _null_;
dcl odsout obj();
run;
/*Slide 2 with a gridded layout*/
ods layout gridded;
ods graphics / width=8in height=3in;
ods region ;
proc sgplot data = cars;
vbar Make / response=TotMSRP
nostatlabel name="bar" nooutline;
yaxis min=0 offsetmin=0 values=(0 to 1650000 by 150000) grid
label="Total MSRP";
xaxis display=(noticks nolabel);
run;
ods layout end;
ods layout gridded columns=2;
ods region;
proc odslist;
item;
p "Car Makes" / style={fontweight=bold fontsize=10pt};
list;
item "Acura" / style={fontsize=10pt};
item "Audi" / style={fontsize=10pt};
item "BMW" / style={fontsize=10pt};
item "Buick" / style={fontsize=10pt};
item "ETC" / style={fontsize=10pt};
end;
end;
run;
ods region;
proc odslist;
item;
p "Car Makes" / style={fontweight=bold fontsize=10pt};
list;
item "Acura" / style={fontsize=10pt};
item "Audi" / style={fontsize=10pt};
item "BMW" / style={fontsize=10pt};
item "Buick" / style={fontsize=10pt};
item "ETC" / style={fontsize=10pt};
end;
end;
run;
ods layout end;
ods powerpoint close;
This works well. One thing that I did notice when I tried to apply this solution to my actual working problem is that it did not work perfectly when trying to create back-to-back slides with custom layouts when utilizing Title statements. Creating one slide with titles and footnotes worked fine. But when I tried to add another custom layout slide after the first custom slide, the second slide was basically overwritten on the first. I found that when I removed the Title statements from each of the slides, that the slides were created correctly, one after another (obviously without titles though). I am using the NOGTITLE and NOGFOOTNOTE options on the ODS PowerPoint statement. I guess this is something that I will just have to continue to look into and figure out what is causing the issue.
Thanks for the responses! I checked with tech support and Jane set me along the right path.
This way her reply:
"...It is possible to create the output that you want. There are a couple of things to note.
ODS PowerPoint will not start a second slide until the first one is full. Sometimes this means a graph is placed on the first slide but it is really small. In that circumstance you have to force a new slide with a DATA _NULL_ step -- I have included that step in the attached code.
Another thing is that column_span and row_span do not work as well in PowerPoint as they do in PDF or HTML. Therefore, I recommend that you create a separate layout container for the graph that you want to span two columns..."
Below is the revised code Jane from tech support sent me:
proc sql;
create table cars as
select Make,
sum(MSRP) as TotMSRP format=dollar10.
from sashelp.cars
group by Make;
quit;
ods _all_ close;
title;
ods powerpoint file='test.pptx';
/*Slide 1 with text in bottom left corner.*/
proc odstext;
p "";
p "";
p "";
p "";
p "";
p "";
p "";
p "";
p "Daily Report" / style={fontweight=bold fontsize=36pt};
p "%sYsFunc(putn(%sYsFunc(today()),WeekDate.))" / style={fontweight=bold fontsize=20pt};
run;
/*insert slide break*/
data _null_;
dcl odsout obj();
run;
/*Slide 2 with a gridded layout*/
ods layout gridded;
ods graphics / width=8in height=3in;
ods region ;
proc sgplot data = cars;
vbar Make / response=TotMSRP
nostatlabel name="bar" nooutline;
yaxis min=0 offsetmin=0 values=(0 to 1650000 by 150000) grid
label="Total MSRP";
xaxis display=(noticks nolabel);
run;
ods layout end;
ods layout gridded columns=2;
ods region;
proc odslist;
item;
p "Car Makes" / style={fontweight=bold fontsize=10pt};
list;
item "Acura" / style={fontsize=10pt};
item "Audi" / style={fontsize=10pt};
item "BMW" / style={fontsize=10pt};
item "Buick" / style={fontsize=10pt};
item "ETC" / style={fontsize=10pt};
end;
end;
run;
ods region;
proc odslist;
item;
p "Car Makes" / style={fontweight=bold fontsize=10pt};
list;
item "Acura" / style={fontsize=10pt};
item "Audi" / style={fontsize=10pt};
item "BMW" / style={fontsize=10pt};
item "Buick" / style={fontsize=10pt};
item "ETC" / style={fontsize=10pt};
end;
end;
run;
ods layout end;
ods powerpoint close;
This works well. One thing that I did notice when I tried to apply this solution to my actual working problem is that it did not work perfectly when trying to create back-to-back slides with custom layouts when utilizing Title statements. Creating one slide with titles and footnotes worked fine. But when I tried to add another custom layout slide after the first custom slide, the second slide was basically overwritten on the first. I found that when I removed the Title statements from each of the slides, that the slides were created correctly, one after another (obviously without titles though). I am using the NOGTITLE and NOGFOOTNOTE options on the ODS PowerPoint statement. I guess this is something that I will just have to continue to look into and figure out what is causing the issue.
Did you ever find a solution for inclusion of Titles? I had the same exact issue, I removed the Titles and it now works fine. But wondering if I can get them back in there?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.