Hi all,
I am having two doubts.
1. How to get a title inside the graph? (using SGPANEL)
2. how to divide the graph into multiple partitions? (SGPANEL. is preferable)
I have attached the sample graph file also..
Thanks.
data test;
do i=1 to 3;
do j=1 to 10;
if j in (1:3) then b=1;
if j in (4:6) then b=2;
if j in (7:10) then b=3;
k=rand('integer', 1, 10);
output;
end;
end;
run;
data test;
set test;
by i b;
retain temp;
if first.b then temp=j;
if last.b then do;r=j;hl=0;l=temp-1;h=j;end;
run;
proc sgpanel data=test noautolegend;
panelby i/ layout=panel novarname spacing=4 columns=1 onepanel ;
highlow y=hl low=l high=h/group=b type=bar barwidth=0.5 nooutline;
block x=j block=b/transparency=0.5 nooutline valuevalign=bottom nofill ;
refline r/axis=x lineattrs=(pattern=dash);
series x=j y=k /markers datalabel datalabelattrs=(color=red)
markerattrs=(symbol=circlefilled) filledoutlinedmarkers markerfillattrs=(color=blue) ;
colaxis grid fitpolicy=none;
rowaxis min=0 offsetmin=0 offsetmax=0;
run;
Hi and welcome to the SAS communities 🙂
Regarding your first question, you can use the INSET Statement like below. The concept works for PROC SGPANEL as well
proc sgplot data=sashelp.class;
scatter x=height y=weight;
inset (' '= "Some Title") / position=top textattrs=(Size=12 Weight=Bold);
run;
For your second question: Can you provide some sample of what your data looks like? Makes it much easier to provide a usable code answer.
Thanks a lot for your quick reply...
Still, I am getting following error...
43 proc sgpanel data=graphlb noautolegend nocycleattrs;
844 panelby lbtestcd / onepanel layout=rowlattice uniscale=column novarname spacing=0;
845 /* band x=x lower=low upper=high / transparency=0.6 fill nooutline*/
846 /* fillattrs=(color=lightblue); */
847 inset (' '= "LBTEST") / position=top textattrs=(Size=12 Weight=Bold);
-
22
76
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, /, _ALL_, _CHARACTER_,
_CHAR_, _NUMERIC_.
ERROR 76-322: Syntax error, statement will be ignored.
848 series x=visitnum y=LBSTRESN /
849 lineattrs=(pattern=solid thickness=3) nomissinggroup name='bp'
849! markerattrs=(symbol=circlefilled size=11);
850 scatter x=visitnum y=LBSTRESN / markerattrs=(symbol=circlefilled size=11);
851 scatter x=visitnum y=LBSTRESN / markerattrs=(symbol=circlefilled size=5 color=white );
852
853 rowaxis grid display=(nolabel) offsetmax=0.1 ;
854 colaxis grid label='Study Days' offsetmax=0.02 values=(1,2,5,8);
855 format visitnum vsexp.;
I have attached a sample graph below..
856 run;
No need proc sgpanel. You need BLOCK statement.
https://blogs.sas.com/content/graphicallyspeaking/2014/04/14/the-block-plot/
data have;
set sashelp.air;
year=year(date);
run;
proc sgplot data=have;
block x=date block=year/transparency=0.5 nooutline VALUEVALIGN=bottom ;
series x=date y=air /markers;
inset 'xxxxxxxxxxxxx'/ position=top textattrs=(size=20);
xaxis valuesformat=date9.;
run;
Thank you so much for your quick reply...
Still, I am getting following error...
proc sgpanel data=graphlb noautolegend nocycleattrs;
811 panelby lbtestcd / onepanel layout=rowlattice uniscale=column novarname spacing=0;
812 /* band x=x lower=low upper=high / transparency=0.6 fill nooutline*/
813 /* fillattrs=(color=lightblue); */
814 inset 'LBTESTCD'/ position=top textattrs=(size=20);
----------
22
200
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, /, _ALL_, _CHARACTER_,
_CHAR_, _NUMERIC_.
ERROR 200-322: The symbol is not recognized and will be ignored.
815 series x=visitnum y=LBSTRESN /
816 lineattrs=(pattern=solid thickness=3) nomissinggroup name='bp'
816! markerattrs=(symbol=circlefilled size=11);
817 scatter x=visitnum y=LBSTRESN / markerattrs=(symbol=circlefilled size=11);
818 scatter x=visitnum y=LBSTRESN / markerattrs=(symbol=circlefilled size=5 color=white );
819
820 rowaxis grid display=(nolabel) offsetmax=0.1 ;
821 colaxis grid label='Study Days' offsetmax=0.02 values=(1,2,5,8);
822 format visitnum vsexp.;
823 run;
Are you sure you want to use PROC SGPANEL here? Or is the solution provided by @Ksharp with the BLOCK Statement in PROC SGPLOT sufficient?
I have needed below as my output.
..But, I am getting below diagram as my output.
I am having three doubts...
1. I need to get a small partition area as I have shown in the first diagram...(No need to color all the area of the graph as in the 2nd diagram)
2. How to get title bar inside the graph as I have shown in the first diagram...(I am getting titles in vertical view (refer 2nd diagram))
3. How to get the value of each plot points in the graph.
I have used the following code...
proc sgpanel data=graphlb noautolegend nocycleattrs;
panelby lbtestcd / onepanel layout=rowlattice uniscale=column novarname spacing=0;
/* band x=x lower=low upper=high / transparency=0.6 fill nooutline*/
/* fillattrs=(color=lightblue); */
/* inset (' '= "LBTEST") / position=top textattrs=(Size=12 Weight=Bold);*/
block x=visitnum block=LBSTRESN/transparency=0.5 nooutline VALUEVALIGN=bottom ;
series x=visitnum y=LBSTRESN /
lineattrs=(pattern=solid thickness=3) nomissinggroup name='bp' markerattrs=(symbol=circlefilled size=11);
scatter x=visitnum y=LBSTRESN / markerattrs=(symbol=circlefilled size=11);
scatter x=visitnum y=LBSTRESN / markerattrs=(symbol=circlefilled size=5 color=white );
rowaxis grid display=(nolabel) offsetmax=0.1 ;
colaxis grid label='Study Days' offsetmax=0.02 values=(1,2,5,8);
format visitnum vsexp.;
run;
Thanks in Advance...
Do not use quote .
inset 'LBTESTCD'/ position=top textattrs=(size=20);
-->
inset LBTESTCD/ position=top textattrs=(size=20);
data test;
do i=1 to 3;
do j=1 to 10;
if j in (1:3) then b=1;
if j in (4:6) then b=2;
if j in (7:10) then b=3;
k=rand('integer', 1, 10);
output;
end;
end;
run;
data test;
set test;
by i b;
retain temp;
if first.b then temp=j;
if last.b then do;r=j;hl=0;l=temp-1;h=j;end;
run;
proc sgpanel data=test noautolegend;
panelby i/ layout=panel novarname spacing=4 columns=1 onepanel ;
highlow y=hl low=l high=h/group=b type=bar barwidth=0.5 nooutline;
block x=j block=b/transparency=0.5 nooutline valuevalign=bottom nofill ;
refline r/axis=x lineattrs=(pattern=dash);
series x=j y=k /markers datalabel datalabelattrs=(color=red)
markerattrs=(symbol=circlefilled) filledoutlinedmarkers markerfillattrs=(color=blue) ;
colaxis grid fitpolicy=none;
rowaxis min=0 offsetmin=0 offsetmax=0;
run;
Thanks a lot for the logic...Iam getting my desired output...
Adding the text from TITLE and FOOTNOTE statements into the image created by ODS Graphics you need to specify the GTITLE and GFOOTNOTE options when opening your ODS destination. See sample code below, for the second graph the title and footnote will not be part of the image.
ods html file="c:\temp\sample.html" gtitle gfootnote;
title "my title";
footnote "my footnote";
proc sgplot data=sashelp.cars;
vbar type / group=origin;
run;
ods html nogtitle nogfootnote;
proc sgplot data=sashelp.cars;
vbar type / group=origin;
run;
title;
footnote;
ods html close;
Hi all,
1. I need to get an output as my second diagram but I am getting a 1st diagram as my output. The problem is column title and border-bottom is overlaying each other.
I have used proc report and ods pdf
Thanks.
Hi all,
1. I need to get an output as my second diagram but I am getting a 1st diagram as my output.
The problem is column title and border-bottom is overlaying each other.
I have used proc report and ods pdf
Thanks.
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.