BookmarkSubscribeRSS Feed
zzh4434
Fluorite | Level 6

The label of axes of the three cells are the same. How to merge the labels of the  axes,like this picture!

 

微信图片_20220601151122.png

this is my code

proc template;                                                                
	define statgraph Series;                                                   
	begingraph;  
    layout lattice / rows=1 columns = 3 rowdatarange=UNIONALL columndatarange=unionall ;
        /* Column and row axes */
        columnaxes;
          columnaxis / display=all label="Mean Ctrough (Days 85 and 92), ng/mL"
					   linearopts=(TICKVALUELIST=(0 100 200 300 400 500 600 ) tickvaluepriority= true);
         columnaxis / display=all label="Mean Ctrough (Days 85 and 92), ng/mL"
					   linearopts=(TICKVALUELIST=(0 100 200 300 400 500 600 ) tickvaluepriority= true);
         columnaxis / display=all label="Mean Ctrough (Days 85 and 92), ng/mL"
					   linearopts=(TICKVALUELIST=(0 100 200 300 400 500 600 ) tickvaluepriority= true);
       endcolumnaxes;
        rowaxes;
          rowaxis / label="% Change from Baseline"
					linearopts=(tickvaluesequence=(start=-100 end=200 increment=50) tickvaluepriority= true);
        endrowaxes;

        **Column 1 content;
 		layout overlay;
			entry halign=center textattrs=(size=9pt) "ApoC-III" /valign=top;
			scatterplot x=aval y=pchg1 /group=group  name="group" markerattrs=(size=10);
			regressionplot  x=aval y=pchg1 /lineattrs=(thickness=4 color=green) degree=3;
	    endlayout;
        **Column 2 content;
 		layout overlay;
			entry halign=center textattrs=(size=9pt) "TG"/valign=top;
			scatterplot x=aval y=pchg1 /group=group  name="group" markerattrs=(size=10);
			regressionplot  x=aval y=pchg1 /lineattrs=(thickness=4 color=green) degree=3;
	    endlayout;
        **Column 3 content;
 		layout overlay;
			entry halign=center textattrs=(size=9pt) "HDL-C"/valign=top;
			scatterplot x=aval y=pchg3 /group=group  name="group" markerattrs=(size=10);
			regressionplot  x=aval y=pchg3 /lineattrs=(thickness=4 color=green) degree=3;
	    endlayout;
		sidebar / align=top ;
			discretelegend "group" / halign=center across=1 border=false;
		endsidebar;
	endlayout;
  endgraph;
 end;
run;

 

 

7 REPLIES 7
Ksharp
Super User
proc sgpanel data=sashelp.heart;
panelby bp_status/layout=columnlattice onepanel noheader novarname;
inset bp_status/position=top nolabel;
scatter x=height y=weight/group=sex;
run;
ballardw
Super User

If you want tested code you need to provide example data in form of data step code and the Proc Sgrender code to create the graph.

zzh4434
Fluorite | Level 6

sorry!try this!

 

data test;
input USUBJID$	group$	aval	pchg1	pchg2	pchg3@@;
datalines;
1102	G1	22.6	41	184.2	5.5
1103	G1	0	-23.6	-42.1	11.6
1104	G1	62.8	-92.7	-79.2	-3.2
1105	G1	0	-16.2	32.6	14.5
1107	G1	0	-2.6	103.4	28.4
1108	G1	112.1	-88.4	-85.7	49.7
4201	G2	42.4	-73.6	-64.1	20
4204	G2	64.2	-51.9	-34.4	38.9
4206	G2	1	0.5	-10.3	-29.9
5001	G3	85.9	-70.6	-63.7	32.2
5002	G3	272	-89.8	-84.4	70.8
5003	G3	166.4	-80.9	-57.2	-13
;
run;

 

ballardw
Super User

And the Proc SGRENDER to use the template?

zzh4434
Fluorite | Level 6

 

data test;
input USUBJID$	group$	aval	pchg1	pchg2	pchg3@@;
datalines;
1102	G1	22.6	41	184.2	5.5
1103	G1	0	-23.6	-42.1	11.6
1104	G1	62.8	-92.7	-79.2	-3.2
1105	G1	0	-16.2	32.6	14.5
1107	G1	0	-2.6	103.4	28.4
1108	G1	112.1	-88.4	-85.7	49.7
4201	G2	42.4	-73.6	-64.1	20
4204	G2	64.2	-51.9	-34.4	38.9
4206	G2	1	0.5	-10.3	-29.9
5001	G3	85.9	-70.6	-63.7	32.2
5002	G3	272	-89.8	-84.4	70.8
5003	G3	166.4	-80.9	-57.2	-13
;
run;

data attrmap;
	infile datalines dlm="#";
	length Value ID MarkerSymbol MarkerColor$200;
	input Value$ ID$ MarkerSymbol$ MarkerColor$@@;
	datalines;
Monotherapy (Groups 1 and 2) # myid #CircleFilled   #blue
Fibrate Combination (Group 3)# myid #TriangleFilled #red
FCS Monotherapy (Group 4)    # myid #SquareFilled   #green
;
run;
proc sgrender data=final dattrmap=attrmap template=Series;
	dattrvar group="myid";
run;
proc template;                                                                
	define statgraph Series;                                                   
	begingraph;  
    layout lattice / rows=1 columns = 3 rowdatarange=UNIONALL columndatarange=unionall ;
        /* Column and row axes */
        columnaxes;
          columnaxis / display=all label="  "
					   linearopts=(TICKVALUELIST=(0 100 200 300 400 500 600 ) tickvaluepriority= true);
         columnaxis / display=all label="Mean Ctrough (Days 85 and 92), ng/mL"
					   linearopts=(TICKVALUELIST=(0 100 200 300 400 500 600 ) tickvaluepriority= true);
         columnaxis / display=all label="  "
					   linearopts=(TICKVALUELIST=(0 100 200 300 400 500 600 ) tickvaluepriority= true);
       endcolumnaxes;
        rowaxes;
          rowaxis / label="% Change from Baseline"
					linearopts=(tickvaluesequence=(start=-100 end=200 increment=50) tickvaluepriority= true);
        endrowaxes;

        **Column 1 content;
 		layout overlay;
			entry halign=center textattrs=(size=9pt) "ApoC-III" /valign=top;
			scatterplot x=aval y=pchg1 /group=group  name="group" markerattrs=(size=10);
			regressionplot  x=aval y=pchg1 /lineattrs=(thickness=4 color=green) degree=3;
	    endlayout;
        **Column 2 content;
 		layout overlay;
			entry halign=center textattrs=(size=9pt) "TG"/valign=top;
			scatterplot x=aval y=pchg2 /group=group  name="group" markerattrs=(size=10);
			regressionplot  x=aval y=pchg2 /lineattrs=(thickness=4 color=green) degree=3;
	    endlayout;
        **Column 3 content;
 		layout overlay;
			entry halign=center textattrs=(size=9pt) "HDL-C"/valign=top;
			scatterplot x=aval y=pchg3 /group=group  name="group" markerattrs=(size=10);
			regressionplot  x=aval y=pchg3 /lineattrs=(thickness=4 color=green) degree=3;
	    endlayout;
		sidebar / align=top ;
			discretelegend "group" / halign=center across=1 border=false;
		endsidebar;
	endlayout;
  endgraph;
 end;
run;

proc sgrender data=test dattrmap=attrmap template=Series;
dattrvar group="myid";
run;

 

ballardw
Super User

I notice this template is not the same as the first shown and is basically where I would start: just provide actual label text under one column. It displays the label in only the center graph but may get truncated depending on the width of the graph created. You might try the Labelpostion=center and see if you like the look though if the width of the center graph doesn't allow enough space it will still be truncated.

 

OR

        columnaxes;
          columnaxis / display=all label="  "
					   linearopts=(TICKVALUELIST=(0 100 200 300 400 500 600 ) tickvaluepriority= true);
         columnaxis / display=all label="Mean Ctrough*(Days 85 and 92)*ng/mL"
					   linearopts=(TICKVALUELIST=(0 100 200 300 400 500 600 ) tickvaluepriority= true)
                  labelfitpolicy=splitalways labelsplitchar='*'
         ;
         columnaxis / display=all label="  "
					   linearopts=(TICKVALUELIST=(0 100 200 300 400 500 600 ) tickvaluepriority= true);
       endcolumnaxes;

Which will split the label resulting in something similar to this on the Axis splitting the label at the positions of the inserted *:

   Mean Ctrough
(Days 85 and 92)
      ng/mL

Last option might be to suppress the label and use an Annotate data set to write text but that is a last choice as you may have to spend a lot of time with other options to create the space for that label to appear correctly.

 

 


@zzh4434 wrote:

 

data test;
input USUBJID$	group$	aval	pchg1	pchg2	pchg3@@;
datalines;
1102	G1	22.6	41	184.2	5.5
1103	G1	0	-23.6	-42.1	11.6
1104	G1	62.8	-92.7	-79.2	-3.2
1105	G1	0	-16.2	32.6	14.5
1107	G1	0	-2.6	103.4	28.4
1108	G1	112.1	-88.4	-85.7	49.7
4201	G2	42.4	-73.6	-64.1	20
4204	G2	64.2	-51.9	-34.4	38.9
4206	G2	1	0.5	-10.3	-29.9
5001	G3	85.9	-70.6	-63.7	32.2
5002	G3	272	-89.8	-84.4	70.8
5003	G3	166.4	-80.9	-57.2	-13
;
run;

data attrmap;
	infile datalines dlm="#";
	length Value ID MarkerSymbol MarkerColor$200;
	input Value$ ID$ MarkerSymbol$ MarkerColor$@@;
	datalines;
Monotherapy (Groups 1 and 2) # myid #CircleFilled   #blue
Fibrate Combination (Group 3)# myid #TriangleFilled #red
FCS Monotherapy (Group 4)    # myid #SquareFilled   #green
;
run;
proc sgrender data=final dattrmap=attrmap template=Series;
	dattrvar group="myid";
run;
proc template;                                                                
	define statgraph Series;                                                   
	begingraph;  
    layout lattice / rows=1 columns = 3 rowdatarange=UNIONALL columndatarange=unionall ;
        /* Column and row axes */
        columnaxes;
          columnaxis / display=all label="  "
					   linearopts=(TICKVALUELIST=(0 100 200 300 400 500 600 ) tickvaluepriority= true);
         columnaxis / display=all label="Mean Ctrough (Days 85 and 92), ng/mL"
					   linearopts=(TICKVALUELIST=(0 100 200 300 400 500 600 ) tickvaluepriority= true);
         columnaxis / display=all label="  "
					   linearopts=(TICKVALUELIST=(0 100 200 300 400 500 600 ) tickvaluepriority= true);
       endcolumnaxes;
        rowaxes;
          rowaxis / label="% Change from Baseline"
					linearopts=(tickvaluesequence=(start=-100 end=200 increment=50) tickvaluepriority= true);
        endrowaxes;

        **Column 1 content;
 		layout overlay;
			entry halign=center textattrs=(size=9pt) "ApoC-III" /valign=top;
			scatterplot x=aval y=pchg1 /group=group  name="group" markerattrs=(size=10);
			regressionplot  x=aval y=pchg1 /lineattrs=(thickness=4 color=green) degree=3;
	    endlayout;
        **Column 2 content;
 		layout overlay;
			entry halign=center textattrs=(size=9pt) "TG"/valign=top;
			scatterplot x=aval y=pchg2 /group=group  name="group" markerattrs=(size=10);
			regressionplot  x=aval y=pchg2 /lineattrs=(thickness=4 color=green) degree=3;
	    endlayout;
        **Column 3 content;
 		layout overlay;
			entry halign=center textattrs=(size=9pt) "HDL-C"/valign=top;
			scatterplot x=aval y=pchg3 /group=group  name="group" markerattrs=(size=10);
			regressionplot  x=aval y=pchg3 /lineattrs=(thickness=4 color=green) degree=3;
	    endlayout;
		sidebar / align=top ;
			discretelegend "group" / halign=center across=1 border=false;
		endsidebar;
	endlayout;
  endgraph;
 end;
run;

proc sgrender data=test dattrmap=attrmap template=Series;
dattrvar group="myid";
run;

 


 

zzh4434
Fluorite | Level 6

thanks,I wrote three identical columnaxes, and then assigned the labels of 1 and 3 to null. What I want is whether I can just write only one columnaxis,
Then the three cells all display the same x axis, and the label is displayed in the middle cell.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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