The SAS Output Delivery System and reporting techniques

How to get four plots on one page?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

How to get four plots on one page?

Hello, I'm 100% new at SAS. In fact, I only know the basics.

 

I have 8 plots. I have the code to get four of them on one page, but I don't know how to get the other four on the second page. Can you please help me? Here's my code. Whenever and whatever I do, it omits the other four. Can you please, please help me?

ods pdf file='file.pdf' startpage=no;
ods layout start width=10in height=8in; /*identify width and height of entire page leaving room for
margins*/
ods region x=0in width=45% y=5% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #1';
scatter y= HG x=ST;
run;
ods region x=55% width=45% y=5% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #2';
scatter y= HG x=BWT;
run;
ods region x=0 width=45% y=51% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #3';
scatter y= HG x=HBR;
run;
ods region x=55% width=45% y=51% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #4';
scatter y= HG x=HL;
run;
ods layout end;


ods pdf file='file.pdf' startpage=no;
ods layout start width=10in height=8in; /*identify width and height of entire page leaving room for
margins*/
ods region x=0in width=45% y=5% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #5';
scatter y= HG x=AGE;
run;
ods region x=55% width=45% y=5% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #6';
scatter y= HG x=DIGIT3;
run;
ods region x=0 width=45% y=51% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #7';
scatter y= HG x=FC;
run;
ods region x=55% width=45% y=51% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #8';
scatter y= HG x=WC;
run;
ods layout end;

Accepted Solutions
Solution
‎11-28-2017 01:11 PM
SAS Super FREQ
Posts: 8,961

Re: How to get four plots on one page?

Hi:

  Rather than use ODS LAYOUT, I would be tempted to use SGPANEL. You'd have to restructure the data a bit differently, but that is easily done.

 

  Here's what SGPANEL would do, by default putting 4 plots per page in PDF:

sgpanel_example.png

 

The code below takes the data you posted and creates a Plot variable to hold the label on the top of each panel and then creates a VAL variable to hold the value.

 

data alt_proj1(keep=HG Plot VAL);
length Plot $25;
Input HG ST BWT HL HBR AGE DIGIT3 WC FC;

do ordvar = 1 to 8 by 1;
   if ordvar = 1 then do;
      Plot = '#1: ST';
	  val = st;
	  output;
   end;
   else if ordvar = 2 then do;
      Plot = '#2: BWT';
	  val = bwt;
	  output;
   end;
   else if ordvar = 3 then do;
      Plot = '#3: HBR';
	  val = hbr;
	  output;
   end;
   else if ordvar = 4 then do;
      Plot = '#4: HL';
	  val = hl;
	  output;
   end;
   else if ordvar = 5 then do;
      Plot = '#5: AGE';
	  val = age;
	  output;
   end;
   else if ordvar = 6 then do;
      Plot = '#6: DIGIT3';
	  val = digit3;
	  output;
   end;
   else if ordvar = 7 then do;
      Plot = '#7: FC';
	  val = fc;
	  output;
   end;
   else if ordvar = 8 then do;
      Plot = '#8: WC';
	  val = wc;
	  output;
   end;
end;Cards;
63 163 63 17.8 7.6 22 7.6 15.7 27
25 169 52.2 17.6 7.3 26	7.9	13.5 21
70 177.8 102.1 21.6	8.9	19 8.9 18.3 33
55 172.7 61.2 21 8.9 18	8.3 15.2 25.7
62 170 83.3	17.6 7.9 27	7.5	16.6 28
25 160 46.5	17.4 6.8 18	8.2	14.5 20.7
66 168 63.1	18.5 8.1 18	7.9	15.8 24.9
66 173 63.5	18.6 8.4 27	8.3	16.2 25.4
81 182 109.7 19 9.5 18 9.2 19.5 30.5
72 182 97 19 8.5 21 8 18 31
65 197 81.3 20 8 21	8 17 15
45 173 83 18.3 8.4 22 8.5 17 31
41 158 73 18 8.4 27	7.5	16.5 27.5
58 177 80.3	18.7 8.5 22	7.6	17.2 27.6
68 182.9 69.4 20.4 8.4 22 8.5 17.5 25.5
44 172.7 72.6 17.9 8.2 18 7.9 16.5 26.5
65 186 77.4	21 8.3 25 9.3 16.5 26
69 181 83 18.3 8 21	8.3	19 25
65 167 102.4 18	8.7	23 7.5 22.6	28.7
62 174 92 18.8 8.8 25 8.5 17 28.4
52 178 69 19.3 7.9 25 8.4 16.5 25.2
51 170 82.5	18.9 8.4 25 7.9	17.5 28
55 173 83.7	17.9 7.9 26 7.8	17.2 29.8
48 166 62.4	20 8.2 25 8.3 16.3 26.7
47 174 81 17.6 7.5 29 7.5 16 26
38 159 62.1	16.4 6.7 21	7.1	14.4 23.6
75 174 162 20.2 8.6	25 8.2 17.5	31.4
51 167.5 77.8 19.8 8.2 24 8.2 17.7 28.3
54 176 63.9	19.4 7.9 22 8.3	15.7 25
51 186 76.2	19.6 8.4 25 8 17.2 29
46 168 75.2	16.5 7 22 7.1 16.3 24.7
54 182 117.8 19	10 23 8	20.4 32.5
74 187 91.8	20 8.5 23 8.7 18.1 30
37 157.5 54.4 16.5 7 20	6.8	15.2 24
60 172.7 74.8 17.9 7.9 21 7.8 17.8 28.6
78 185.4 82.6 19 9 24 9 18.6 29.2
53 175 74.4	18 8 20 7.4	17 26
55 168 84.5	17.6 8.5 20 8.1	16.6 27.5
71 172 86.5	18.5 9 20 8.5 17.5 28.4
66 177 97.1	19.5 8.5 20	9 16.9 28.5
42 166 78.8	18 8.5 22 7.7 17.5 28.7
53.5 161 65.1 17.7 7.9 20 7.5 16.5 27.9
78.3 187 90.5 21 9 23 8.5 18.7 30
66 169.5 72.9 19.3 8.5 24 8.7 18 27.2
36 164 57 19.4 6.6 27 8.9 15 22.7
39 154.5 65.8 16.9 7 22	7.5	15 26
43.5 166 64.1 18.4 7.2 20 8.3 15 26.8
64 154.4 91	18.6 8.3 20	7.4	18.3 27.4
39 166.5 53	17.9 7.6 22	8 14.6 13
57 188 69.4	18.5 8.5 20	7.9	16.2 16.3
52 178 69.6	19.3 7.9 25	8.4	16.5 25.2
51 170 87.5	18.9 8.4 25	7.9	17.5 28
55 173 83.7	17.9 7.9 26	7.8	17.2 29.8
62 174 92 18.8 8.8 25 8.5 16.7 28.4
74 180 75.4	21.5 8.8 21	9.3	17.1 27.5
55 187 92.4	20.3 8.7 21	8.5	18.5 30.2
68.9 179 102.7 20.1 8.4 19 8.6 18.4 28.9
53.5 182.3 76 21.8 8.4 19 8.5 17.7 23.5
42.4 180 63.6 20 8.3 21	8.8	15.9 27
36 164 57 19.4 6.6 27 8.9 15 22.7
39 154.5 65.8 16.9 7 22	7.5	15 26
43.5 166 64.1 18.4 7.2 20 8.3 15 26.8
50 162 68.3	18 9 19 7.8	17.3 26
72 170.5 108.4 18.2	9.1	19 7.9 18.3	32
58 187 99.7	19 9 18	7.7	17.3 28.8
63 174 82.8	18 8.5 18 7.5 17 27.7
51 167.5 68.6 18.3 8.2 22 8 17.7 26
65 182 81 21 9.4 18	9 18.3 29.2
47 159 73 17.7 8 18	7.2	16.5 25.9
35 165 67.6 18 8.2 18 8	15.4 24
58 181 175 20 9.6 18 9 20.5	35
66 181 74.6 21 7.7 21 9.4 16.5 27.9
34 156 100 16.4	7.5	22 7 17 27.5
31 163 59.6 17.2 7.4 25 7.1	14.2 21.4
34 165 57 17.5 9 24	8 16 24.2
53 177 71.1	19 7.7 34 8.3 16 25.8
64 183 81.9	18.8 8.4 21	8.5	16.9 25.3
53 186 115.5 20.3 8.9 18 9.3 18.7 29.4
49 178.5 64.7 17.8 8.5 20 8.1 15.8 24.3
56 180 98.2	18.6 8 26 8.2 17.1 29.5
27 178 73.6	18.8 7.6 25	8.3	16 25.8
45 161 55.6	17.5 8 23 7.5 15 22.5
63 163 64.2	17.4 8 22 7.5 15.5 26
45 168 85.7	18.5 9 20 7.5 16.8 26
49 178 77.1	18.7 8.5 20 8.3	17 25.5
61 176 75.3	18.9 8.6 21	8.2	17.1 27.9
53 175 90 19 8.5 21	8 18.5 28.6
40 165 63.5	17.8 8 24 7.8 15.8 23.5
65 186 77.4	21 8.3 25 9.3 16.5 26
69 181 83 18.3 8 21	8.3	19 25
65 167 102.4 18	8.7	23 7.5 22.6 28.7
62 174 92 18.8 8.8 25 8.5 17 28.4
52 178 69 19.3 7.9 25 8.4 16.5 25.2
51 170 82.5 18.9 8.4 25 7.9	17.5 28
55 173 83.7 17.9 7.9 26	7.8	17.2 29.8
48 166 62.4 20 8.2 25 8.3 16.3 26.7
47 174 81 17.6 7.5 29 7.5 16 26
38 159 62.1 16.4 6.7 21 7.1	14.4 23.6
75 174 62 20.2 8.6 25 8.2 17.5 31.4
;
run;
  
title; footnote;
ods pdf file='/folders/myfolders/sgpanel_alt.pdf' ;
 proc sgpanel data= alt_proj1;
 panelby Plot;
scatter y= HG x=val;
run;

ods pdf close;

Just an idea. Very frequently, SGPANEL makes the right or most logical decision about how to create the panels.

 

Cynthia

View solution in original post


All Replies
Super User
Posts: 20,731

Re: How to get four plots on one page?

[ Edited ]

You have two of these:

 

ods pdf file='file.pdf' startpage=no;

It doesn't make sense to have a new FILE in the statement because you're not creating a new file. 

If you want to start a new page, I think it's startpage=yes or startpage=now, but then you have to turn it off again.

 

ods pdf  startpage=now;

 

You can check the ODS PDF cheat sheet to see what the options are:

 

https://support.sas.com/rnd/base/ods/odsprinter/PDF-tips.pdf

 

 


TagIt2 wrote:

Hello, I'm 100% new at SAS. In fact, I only know the basics.

 

I have 8 plots. I have the code to get four of them on one page, but I don't know how to get the other four on the second page. Can you please help me? Here's my code. Whenever and whatever I do, it omits the other four. Can you please, please help me?

ods pdf file='file.pdf' startpage=no;
ods layout start width=10in height=8in; /*identify width and height of entire page leaving room for
margins*/
ods region x=0in width=45% y=5% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #1';
scatter y= HG x=ST;
run;
ods region x=55% width=45% y=5% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #2';
scatter y= HG x=BWT;
run;
ods region x=0 width=45% y=51% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #3';
scatter y= HG x=HBR;
run;
ods region x=55% width=45% y=51% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #4';
scatter y= HG x=HL;
run;
ods layout end;


ods pdf file='file.pdf' startpage=no;
ods layout start width=10in height=8in; /*identify width and height of entire page leaving room for
margins*/
ods region x=0in width=45% y=5% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #5';
scatter y= HG x=AGE;
run;
ods region x=55% width=45% y=5% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #6';
scatter y= HG x=DIGIT3;
run;
ods region x=0 width=45% y=51% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #7';
scatter y= HG x=FC;
run;
ods region x=55% width=45% y=51% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #8';
scatter y= HG x=WC;
run;
ods layout end;

 

Occasional Contributor
Posts: 5

Re: How to get four plots on one page?

You're definitely right and that makes sense. When I delete that part and add the new page part, it only gives plots 5 through 8. 

Do you think you could help? Or is there a better way?

 

ods pdf file='file.pdf' startpage=no;
ods layout start width=10in height=8in; /*identify width and height of entire page leaving room for
margins*/
ods region x=0in width=45% y=5% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #1';
scatter y= HG x=ST;
run;
ods region x=55% width=45% y=5% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #2';
scatter y= HG x=BWT;
run;
ods region x=0 width=45% y=51% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #3';
scatter y= HG x=HBR;
run;
ods region x=55% width=45% y=51% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #4';
scatter y= HG x=HL;
run;
ods layout end;

ods pdf startpage=yes;
ods layout start width=10in height=8in; /*identify width and height of entire page leaving room for
margins*/
ods region x=0in width=45% y=5% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #5';
scatter y= HG x=AGE;
run;
ods region x=55% width=45% y=5% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #6';
scatter y= HG x=DIGIT3;
run;
ods region x=0 width=45% y=51% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #7';
scatter y= HG x=FC;
run;
ods region x=55% width=45% y=51% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #8';
scatter y= HG x=WC;
run;
ods layout end;

 

Super User
Posts: 20,731

Re: How to get four plots on one page?

I don't see an ODS PDF CLOSE statement at the end? Does NOW not work?

 

I'm not familiar with ODS LAYOUT so I can't help with that, but I've moved the post to the ODS and Base Reporting so if this doesn't solve your issues, someone else should be able to help. 

Occasional Contributor
Posts: 5

Re: How to get four plots on one page?

Whenever I add ODS PDF Close it gives me this error: Insufficient authorization to access /opt/sasinside/SASConfig/Lev1/SASApp/file.pdf

 

That was one of the first things I did based on a Google search...


Thanks for your help!

Super User
Posts: 20,731

Re: How to get four plots on one page?

Post your full code and log. I suspect there's something else wrong....

Occasional Contributor
Posts: 5

Re: How to get four plots on one page?

This is my full code

 

Data Project1;

Input HG ST BWT HL HBR AGE DIGIT3 WC FC;

Cards;

63 163 63 17.8 7.6 22 7.6 15.7 27
25 169 52.2 17.6 7.3 26	7.9	13.5 21
70 177.8 102.1 21.6	8.9	19 8.9 18.3 33
55 172.7 61.2 21 8.9 18	8.3 15.2 25.7
62 170 83.3	17.6 7.9 27	7.5	16.6 28
25 160 46.5	17.4 6.8 18	8.2	14.5 20.7
66 168 63.1	18.5 8.1 18	7.9	15.8 24.9
66 173 63.5	18.6 8.4 27	8.3	16.2 25.4
81 182 109.7 19 9.5 18 9.2 19.5 30.5
72 182 97 19 8.5 21 8 18 31
65 197 81.3 20 8 21	8 17 15
45 173 83 18.3 8.4 22 8.5 17 31
41 158 73 18 8.4 27	7.5	16.5 27.5
58 177 80.3	18.7 8.5 22	7.6	17.2 27.6
68 182.9 69.4 20.4 8.4 22 8.5 17.5 25.5
44 172.7 72.6 17.9 8.2 18 7.9 16.5 26.5
65 186 77.4	21 8.3 25 9.3 16.5 26
69 181 83 18.3 8 21	8.3	19 25
65 167 102.4 18	8.7	23 7.5 22.6	28.7
62 174 92 18.8 8.8 25 8.5 17 28.4
52 178 69 19.3 7.9 25 8.4 16.5 25.2
51 170 82.5	18.9 8.4 25 7.9	17.5 28
55 173 83.7	17.9 7.9 26 7.8	17.2 29.8
48 166 62.4	20 8.2 25 8.3 16.3 26.7
47 174 81 17.6 7.5 29 7.5 16 26
38 159 62.1	16.4 6.7 21	7.1	14.4 23.6
75 174 162 20.2 8.6	25 8.2 17.5	31.4
51 167.5 77.8 19.8 8.2 24 8.2 17.7 28.3
54 176 63.9	19.4 7.9 22 8.3	15.7 25
51 186 76.2	19.6 8.4 25 8 17.2 29
46 168 75.2	16.5 7 22 7.1 16.3 24.7
54 182 117.8 19	10 23 8	20.4 32.5
74 187 91.8	20 8.5 23 8.7 18.1 30
37 157.5 54.4 16.5 7 20	6.8	15.2 24
60 172.7 74.8 17.9 7.9 21 7.8 17.8 28.6
78 185.4 82.6 19 9 24 9 18.6 29.2
53 175 74.4	18 8 20 7.4	17 26
55 168 84.5	17.6 8.5 20 8.1	16.6 27.5
71 172 86.5	18.5 9 20 8.5 17.5 28.4
66 177 97.1	19.5 8.5 20	9 16.9 28.5
42 166 78.8	18 8.5 22 7.7 17.5 28.7
53.5 161 65.1 17.7 7.9 20 7.5 16.5 27.9
78.3 187 90.5 21 9 23 8.5 18.7 30
66 169.5 72.9 19.3 8.5 24 8.7 18 27.2
36 164 57 19.4 6.6 27 8.9 15 22.7
39 154.5 65.8 16.9 7 22	7.5	15 26
43.5 166 64.1 18.4 7.2 20 8.3 15 26.8
64 154.4 91	18.6 8.3 20	7.4	18.3 27.4
39 166.5 53	17.9 7.6 22	8 14.6 13
57 188 69.4	18.5 8.5 20	7.9	16.2 16.3
52 178 69.6	19.3 7.9 25	8.4	16.5 25.2
51 170 87.5	18.9 8.4 25	7.9	17.5 28
55 173 83.7	17.9 7.9 26	7.8	17.2 29.8
62 174 92 18.8 8.8 25 8.5 16.7 28.4
74 180 75.4	21.5 8.8 21	9.3	17.1 27.5
55 187 92.4	20.3 8.7 21	8.5	18.5 30.2
68.9 179 102.7 20.1 8.4 19 8.6 18.4 28.9
53.5 182.3 76 21.8 8.4 19 8.5 17.7 23.5
42.4 180 63.6 20 8.3 21	8.8	15.9 27
36 164 57 19.4 6.6 27 8.9 15 22.7
39 154.5 65.8 16.9 7 22	7.5	15 26
43.5 166 64.1 18.4 7.2 20 8.3 15 26.8
50 162 68.3	18 9 19 7.8	17.3 26
72 170.5 108.4 18.2	9.1	19 7.9 18.3	32
58 187 99.7	19 9 18	7.7	17.3 28.8
63 174 82.8	18 8.5 18 7.5 17 27.7
51 167.5 68.6 18.3 8.2 22 8 17.7 26
65 182 81 21 9.4 18	9 18.3 29.2
47 159 73 17.7 8 18	7.2	16.5 25.9
35 165 67.6 18 8.2 18 8	15.4 24
58 181 175 20 9.6 18 9 20.5	35
66 181 74.6 21 7.7 21 9.4 16.5 27.9
34 156 100 16.4	7.5	22 7 17 27.5
31 163 59.6 17.2 7.4 25 7.1	14.2 21.4
34 165 57 17.5 9 24	8 16 24.2
53 177 71.1	19 7.7 34 8.3 16 25.8
64 183 81.9	18.8 8.4 21	8.5	16.9 25.3
53 186 115.5 20.3 8.9 18 9.3 18.7 29.4
49 178.5 64.7 17.8 8.5 20 8.1 15.8 24.3
56 180 98.2	18.6 8 26 8.2 17.1 29.5
27 178 73.6	18.8 7.6 25	8.3	16 25.8
45 161 55.6	17.5 8 23 7.5 15 22.5
63 163 64.2	17.4 8 22 7.5 15.5 26
45 168 85.7	18.5 9 20 7.5 16.8 26
49 178 77.1	18.7 8.5 20 8.3	17 25.5
61 176 75.3	18.9 8.6 21	8.2	17.1 27.9
53 175 90 19 8.5 21	8 18.5 28.6
40 165 63.5	17.8 8 24 7.8 15.8 23.5
65 186 77.4	21 8.3 25 9.3 16.5 26
69 181 83 18.3 8 21	8.3	19 25
65 167 102.4 18	8.7	23 7.5 22.6 28.7
62 174 92 18.8 8.8 25 8.5 17 28.4
52 178 69 19.3 7.9 25 8.4 16.5 25.2
51 170 82.5 18.9 8.4 25 7.9	17.5 28
55 173 83.7 17.9 7.9 26	7.8	17.2 29.8
48 166 62.4 20 8.2 25 8.3 16.3 26.7
47 174 81 17.6 7.5 29 7.5 16 26
38 159 62.1 16.4 6.7 21 7.1	14.4 23.6
75 174 62 20.2 8.6 25 8.2 17.5 31.4
;

ods pdf file='file.pdf' startpage=no;
ods layout start width=10in height=8in; /*identify width and height of entire page leaving room for
margins*/
ods region x=0in width=45% y=5% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #1';
scatter y= HG x=ST;
run;
ods region x=55% width=45% y=5% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #2';
scatter y= HG x=BWT;
run;
ods region x=0 width=45% y=51% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #3';
scatter y= HG x=HBR;
run;
ods region x=55% width=45% y=51% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #4';
scatkmter y= HG x=HL;
run;
ods layout end;

ods pdf startpage=now;
ods layout start width=10in height=8in; /*identify width and height of entire page leaving room for
margins*/
ods region x=0in width=45% y=5% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #5';
scatter y= HG x=AGE;
run;
ods region x=55% width=45% y=5% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #6';
scatter y= HG x=DIGIT3;
run;
ods region x=0 width=45% y=51% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #7';
scatter y= HG x=FC;
run;
ods region x=55% width=45% y=51% height=45%; /*identify region boundaries*/
proc sgplot data= Project1;
title2 'PLOT #8';
scatter y= HG x=WC;
run;
ods layout end;
ODS PDF close;

Proc Corr;

Proc Reg; Model HG = ST BWT HL HBR AGE DIGIT3 WC FC/ ALL;

Run;
Super User
Posts: 11,810

Re: How to get four plots on one page?


TagIt2 wrote:

Whenever I add ODS PDF Close it gives me this error: Insufficient authorization to access /opt/sasinside/SASConfig/Lev1/SASApp/file.pdf

 

That was one of the first things I did based on a Google search...


Thanks for your help!


That type of error message usually means you are attempting to create a file where you do not have permissions. You may need to work with your SAS admin to determine where you can create files. It is a good idea to specify a complete path to your target destination so you don't attempt to write to areas in the SAS install folders.

Occasional Contributor
Posts: 5

Re: How to get four plots on one page?

I don't know if there is an Admin for me. I'm using SAS University Edition if that changes anything?

Super User
Posts: 20,731

Re: How to get four plots on one page?

Where's the log? 

 

Are you actually using file.pdf or did you mask the path, I'd assumed you masked the path.....

Do you actually want a PDF file?

 

The stuff beyond ODS PDF is definitely wrong, but that's not what you're asking about here and should be another question. 

 

I suspect it's the the file path you need to set properly. 

 

ods pdf file='/folders/myfolders/Sample PDF.pdf' startpage=no;
Solution
‎11-28-2017 01:11 PM
SAS Super FREQ
Posts: 8,961

Re: How to get four plots on one page?

Hi:

  Rather than use ODS LAYOUT, I would be tempted to use SGPANEL. You'd have to restructure the data a bit differently, but that is easily done.

 

  Here's what SGPANEL would do, by default putting 4 plots per page in PDF:

sgpanel_example.png

 

The code below takes the data you posted and creates a Plot variable to hold the label on the top of each panel and then creates a VAL variable to hold the value.

 

data alt_proj1(keep=HG Plot VAL);
length Plot $25;
Input HG ST BWT HL HBR AGE DIGIT3 WC FC;

do ordvar = 1 to 8 by 1;
   if ordvar = 1 then do;
      Plot = '#1: ST';
	  val = st;
	  output;
   end;
   else if ordvar = 2 then do;
      Plot = '#2: BWT';
	  val = bwt;
	  output;
   end;
   else if ordvar = 3 then do;
      Plot = '#3: HBR';
	  val = hbr;
	  output;
   end;
   else if ordvar = 4 then do;
      Plot = '#4: HL';
	  val = hl;
	  output;
   end;
   else if ordvar = 5 then do;
      Plot = '#5: AGE';
	  val = age;
	  output;
   end;
   else if ordvar = 6 then do;
      Plot = '#6: DIGIT3';
	  val = digit3;
	  output;
   end;
   else if ordvar = 7 then do;
      Plot = '#7: FC';
	  val = fc;
	  output;
   end;
   else if ordvar = 8 then do;
      Plot = '#8: WC';
	  val = wc;
	  output;
   end;
end;Cards;
63 163 63 17.8 7.6 22 7.6 15.7 27
25 169 52.2 17.6 7.3 26	7.9	13.5 21
70 177.8 102.1 21.6	8.9	19 8.9 18.3 33
55 172.7 61.2 21 8.9 18	8.3 15.2 25.7
62 170 83.3	17.6 7.9 27	7.5	16.6 28
25 160 46.5	17.4 6.8 18	8.2	14.5 20.7
66 168 63.1	18.5 8.1 18	7.9	15.8 24.9
66 173 63.5	18.6 8.4 27	8.3	16.2 25.4
81 182 109.7 19 9.5 18 9.2 19.5 30.5
72 182 97 19 8.5 21 8 18 31
65 197 81.3 20 8 21	8 17 15
45 173 83 18.3 8.4 22 8.5 17 31
41 158 73 18 8.4 27	7.5	16.5 27.5
58 177 80.3	18.7 8.5 22	7.6	17.2 27.6
68 182.9 69.4 20.4 8.4 22 8.5 17.5 25.5
44 172.7 72.6 17.9 8.2 18 7.9 16.5 26.5
65 186 77.4	21 8.3 25 9.3 16.5 26
69 181 83 18.3 8 21	8.3	19 25
65 167 102.4 18	8.7	23 7.5 22.6	28.7
62 174 92 18.8 8.8 25 8.5 17 28.4
52 178 69 19.3 7.9 25 8.4 16.5 25.2
51 170 82.5	18.9 8.4 25 7.9	17.5 28
55 173 83.7	17.9 7.9 26 7.8	17.2 29.8
48 166 62.4	20 8.2 25 8.3 16.3 26.7
47 174 81 17.6 7.5 29 7.5 16 26
38 159 62.1	16.4 6.7 21	7.1	14.4 23.6
75 174 162 20.2 8.6	25 8.2 17.5	31.4
51 167.5 77.8 19.8 8.2 24 8.2 17.7 28.3
54 176 63.9	19.4 7.9 22 8.3	15.7 25
51 186 76.2	19.6 8.4 25 8 17.2 29
46 168 75.2	16.5 7 22 7.1 16.3 24.7
54 182 117.8 19	10 23 8	20.4 32.5
74 187 91.8	20 8.5 23 8.7 18.1 30
37 157.5 54.4 16.5 7 20	6.8	15.2 24
60 172.7 74.8 17.9 7.9 21 7.8 17.8 28.6
78 185.4 82.6 19 9 24 9 18.6 29.2
53 175 74.4	18 8 20 7.4	17 26
55 168 84.5	17.6 8.5 20 8.1	16.6 27.5
71 172 86.5	18.5 9 20 8.5 17.5 28.4
66 177 97.1	19.5 8.5 20	9 16.9 28.5
42 166 78.8	18 8.5 22 7.7 17.5 28.7
53.5 161 65.1 17.7 7.9 20 7.5 16.5 27.9
78.3 187 90.5 21 9 23 8.5 18.7 30
66 169.5 72.9 19.3 8.5 24 8.7 18 27.2
36 164 57 19.4 6.6 27 8.9 15 22.7
39 154.5 65.8 16.9 7 22	7.5	15 26
43.5 166 64.1 18.4 7.2 20 8.3 15 26.8
64 154.4 91	18.6 8.3 20	7.4	18.3 27.4
39 166.5 53	17.9 7.6 22	8 14.6 13
57 188 69.4	18.5 8.5 20	7.9	16.2 16.3
52 178 69.6	19.3 7.9 25	8.4	16.5 25.2
51 170 87.5	18.9 8.4 25	7.9	17.5 28
55 173 83.7	17.9 7.9 26	7.8	17.2 29.8
62 174 92 18.8 8.8 25 8.5 16.7 28.4
74 180 75.4	21.5 8.8 21	9.3	17.1 27.5
55 187 92.4	20.3 8.7 21	8.5	18.5 30.2
68.9 179 102.7 20.1 8.4 19 8.6 18.4 28.9
53.5 182.3 76 21.8 8.4 19 8.5 17.7 23.5
42.4 180 63.6 20 8.3 21	8.8	15.9 27
36 164 57 19.4 6.6 27 8.9 15 22.7
39 154.5 65.8 16.9 7 22	7.5	15 26
43.5 166 64.1 18.4 7.2 20 8.3 15 26.8
50 162 68.3	18 9 19 7.8	17.3 26
72 170.5 108.4 18.2	9.1	19 7.9 18.3	32
58 187 99.7	19 9 18	7.7	17.3 28.8
63 174 82.8	18 8.5 18 7.5 17 27.7
51 167.5 68.6 18.3 8.2 22 8 17.7 26
65 182 81 21 9.4 18	9 18.3 29.2
47 159 73 17.7 8 18	7.2	16.5 25.9
35 165 67.6 18 8.2 18 8	15.4 24
58 181 175 20 9.6 18 9 20.5	35
66 181 74.6 21 7.7 21 9.4 16.5 27.9
34 156 100 16.4	7.5	22 7 17 27.5
31 163 59.6 17.2 7.4 25 7.1	14.2 21.4
34 165 57 17.5 9 24	8 16 24.2
53 177 71.1	19 7.7 34 8.3 16 25.8
64 183 81.9	18.8 8.4 21	8.5	16.9 25.3
53 186 115.5 20.3 8.9 18 9.3 18.7 29.4
49 178.5 64.7 17.8 8.5 20 8.1 15.8 24.3
56 180 98.2	18.6 8 26 8.2 17.1 29.5
27 178 73.6	18.8 7.6 25	8.3	16 25.8
45 161 55.6	17.5 8 23 7.5 15 22.5
63 163 64.2	17.4 8 22 7.5 15.5 26
45 168 85.7	18.5 9 20 7.5 16.8 26
49 178 77.1	18.7 8.5 20 8.3	17 25.5
61 176 75.3	18.9 8.6 21	8.2	17.1 27.9
53 175 90 19 8.5 21	8 18.5 28.6
40 165 63.5	17.8 8 24 7.8 15.8 23.5
65 186 77.4	21 8.3 25 9.3 16.5 26
69 181 83 18.3 8 21	8.3	19 25
65 167 102.4 18	8.7	23 7.5 22.6 28.7
62 174 92 18.8 8.8 25 8.5 17 28.4
52 178 69 19.3 7.9 25 8.4 16.5 25.2
51 170 82.5 18.9 8.4 25 7.9	17.5 28
55 173 83.7 17.9 7.9 26	7.8	17.2 29.8
48 166 62.4 20 8.2 25 8.3 16.3 26.7
47 174 81 17.6 7.5 29 7.5 16 26
38 159 62.1 16.4 6.7 21 7.1	14.4 23.6
75 174 62 20.2 8.6 25 8.2 17.5 31.4
;
run;
  
title; footnote;
ods pdf file='/folders/myfolders/sgpanel_alt.pdf' ;
 proc sgpanel data= alt_proj1;
 panelby Plot;
scatter y= HG x=val;
run;

ods pdf close;

Just an idea. Very frequently, SGPANEL makes the right or most logical decision about how to create the panels.

 

Cynthia

☑ This topic is solved.

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

Discussion stats
  • 11 replies
  • 334 views
  • 0 likes
  • 5 in conversation