Graph SAS图形:将两个绘图的轴与晶格行对齐
我真的在努力解决这个问题,我真的找不到解决办法,我希望,在这里发布,有人会帮助我 问题是,使用这个2格行模板,我无法对齐轴 现在,我详细介绍了我使用代码所做的一切,以重现每个步骤: 我有这个阴谋 这里是图形和示例数据集的代码,它是以下内容的简单版本: 样本数据集:Graph SAS图形:将两个绘图的轴与晶格行对齐,graph,plot,sas,Graph,Plot,Sas,我真的在努力解决这个问题,我真的找不到解决办法,我希望,在这里发布,有人会帮助我 问题是,使用这个2格行模板,我无法对齐轴 现在,我详细介绍了我使用代码所做的一切,以重现每个步骤: 我有这个阴谋 这里是图形和示例数据集的代码,它是以下内容的简单版本: 样本数据集: data immune; format sival f6.3; input trt $ 1-8 cyc $ 10-18 pt lbparm $ xval sival; cards; Drug A Cycle 1
data immune;
format sival f6.3;
input trt $ 1-8 cyc $ 10-18 pt lbparm $ xval sival;
cards;
Drug A Cycle 1 1 C3 1 1.120
Drug A Cycle 1 1 C4 1 0.147
Drug A Cycle 1 1 C3 2 1.080
Drug A Cycle 1 1 C4 2 0.131
Drug A Cycle 1 1 C3 3 0.887
Drug A Cycle 1 1 C4 3 0.113
Drug A Cycle 2 1 C3 4 1.440
Drug A Cycle 2 1 C4 4 0.278
Drug A Cycle 2 1 C3 5 1.180
Drug A Cycle 2 1 C4 5 0.234
Drug A Cycle 2 1 C3 6 1.360
Drug A Cycle 2 1 C4 6 0.281
Drug A Cycle 3 1 C3 7 1.190
Drug A Cycle 3 1 C4 7 0.282
Drug A Cycle 3 1 C3 8 1.000
Drug A Cycle 3 1 C4 8 0.228
Drug A Cycle 3 1 C3 9 1.040
Drug A Cycle 3 1 C4 9 0.228
Drug A Cycle 4 1 C3 10 0.917
Drug A Cycle 4 1 C4 10 0.163
Drug A Cycle 4 1 C3 11 0.789
Drug A Cycle 4 1 C4 11 0.136
Drug A Cycle 4 1 C3 12 0.861
Drug A Cycle 4 1 C4 12 0.148
Drug A Cycle 1 2 C3 1 1.180
Drug A Cycle 1 2 C4 1 0.264
Drug A Cycle 1 2 C3 2 0.942
Drug A Cycle 1 2 C4 2 0.184
Drug A Cycle 1 2 C3 3 1.010
Drug A Cycle 1 2 C4 3 0.160
Drug A Cycle 2 2 C3 4 1.050
Drug A Cycle 2 2 C4 4 0.134
Drug A Cycle 2 2 C3 5 0.980
Drug A Cycle 2 2 C4 5 0.120
Drug A Cycle 2 2 C3 6 1.020
Drug A Cycle 2 2 C4 6 0.126
Drug A Cycle 3 2 C3 7 0.961
Drug A Cycle 3 2 C4 7 0.110
Drug A Cycle 3 2 C3 8 0.859
Drug A Cycle 3 2 C4 8 0.091
Drug A Cycle 3 2 C3 9 0.928
Drug A Cycle 3 2 C4 9 0.097
Drug A Cycle 4 2 C3 10 1.380
Drug A Cycle 4 2 C4 10 0.330
Drug A Cycle 4 2 C3 11 1.210
Drug A Cycle 4 2 C4 11 0.281
Drug A Cycle 4 2 C3 12 1.180
Drug A Cycle 4 2 C4 12 0.278
Drug A Cycle 1 3 C3 1 1.180
Drug A Cycle 1 3 C4 1 0.269
Drug A Cycle 1 3 C3 2 1.010
Drug A Cycle 1 3 C4 2 0.213
Drug A Cycle 1 3 C3 3 1.040
Drug A Cycle 1 3 C4 3 0.200
Drug A Cycle 2 3 C3 4 1.200
Drug A Cycle 2 3 C4 4 0.332
Drug A Cycle 2 3 C4 5 0.371
Drug A Cycle 2 3 C4 6 0.316
Drug A Cycle 3 3 C4 7 0.271
Drug A Cycle 3 3 C3 8 1.050
Drug A Cycle 3 3 C4 8 0.246
Drug A Cycle 3 3 C3 9 1.100
Drug A Cycle 3 3 C4 9 0.248
Drug A Cycle 4 3 C3 10 1.090
Drug A Cycle 4 3 C4 10 0.234
Drug A Cycle 4 3 C3 11 0.937
Drug A Cycle 4 3 C3 12 0.980
Drug A Cycle 1 4 C3 1 1.220
Drug A Cycle 1 4 C4 1 0.182
Drug A Cycle 1 4 C3 2 0.983
Drug A Cycle 1 4 C4 2 0.132
Drug A Cycle 1 4 C3 3 0.979
Drug A Cycle 1 4 C4 3 0.128
Drug A Cycle 2 4 C3 4 1.190
Drug A Cycle 2 4 C4 4 0.134
Drug A Cycle 2 4 C3 5 1.010
Drug A Cycle 2 4 C4 5 0.076
Drug A Cycle 2 4 C3 6 1.100
Drug A Cycle 2 4 C4 6 0.083
Drug A Cycle 3 4 C3 7 1.140
Drug A Cycle 3 4 C4 7 0.108
Drug A Cycle 3 4 C3 8 1.140
Drug A Cycle 3 4 C4 8 0.104
Drug A Cycle 3 4 C3 9 1.120
Drug A Cycle 3 4 C4 9 0.080
;
run;
proc sort data=immune out=sasuser.immune;
by pt;
run;
data firstrow;
length ROW $20 TITLE $20 REASON $50 CHAR $20 VAR $20;
infile datalines dlm=',';
input ROW TITLE REASON CHAR VAR;
datalines;
ROW 1,ROW 1,FIRST REASON,FIRST ROW,FIRST VAR,
ROW 2,ROW 2,SECOND REASON,SECOND ROW,SECOND VAR,
ROW 3,ROW 3,THIRD REASON,THIRD ROW,THIRD VAR,
ROW 4,ROW 4,FOURTH REASON,FOURTH ROW,FOURTH VAR,
;
proc transpose data=firstrow out=firstrow_;
by row;
var title reason char var;
run;
现在,图形的模板代码为:
proc template;
define statgraph gsv00251;
begingraph / designwidth=7in designheight=4.5in;
entrytitle 'Immunology Profile by Treatment';
layout gridded;
layout datalattice rowvar=lbparm /
headerlabeldisplay=value includemissingclass=false
columnaxisopts=(label="Cycle Day" griddisplay=on type=discrete
discreteopts=(tickdisplaylist=
("0" "15" "30" "0" "15" "30" "0" "15" "30" "0" "15" "30"))
offsetmin = .03 offsetmax = .03)
rowaxisopts=(offsetmax=.1 label="Values Converted to SI Units "
griddisplay=on) rowdatarange=union;
layout prototype;
blockplot x=xval block=cyc / datatransparency = .75
display=(outline fill )
name="block" filltype=alternate;
seriesplot x=xval y=sival / group=pt index=pt name='a'
display=all lineattrs=(pattern=1 thickness=2)
markerattrs=(symbol=circlefilled size=8);
endlayout;
endlayout;
entry ' ';
discretelegend 'a' / title='Patient' across=8;
endlayout;
endgraph;
end;
run;
现在,我想在每个块的顶部添加一些信息,因此我在web上进行了一些搜索,发现实现此结果的最佳方法是更改proc模板,添加2个lattice行:
1第一个格子行包含一个区块图,其中包含这些信息,如图中的方框图和统计数据,第二个示例
2包含先前发布的绘图的第二个晶格行
因此,我创建了这个原始样本数据集:
data immune;
format sival f6.3;
input trt $ 1-8 cyc $ 10-18 pt lbparm $ xval sival;
cards;
Drug A Cycle 1 1 C3 1 1.120
Drug A Cycle 1 1 C4 1 0.147
Drug A Cycle 1 1 C3 2 1.080
Drug A Cycle 1 1 C4 2 0.131
Drug A Cycle 1 1 C3 3 0.887
Drug A Cycle 1 1 C4 3 0.113
Drug A Cycle 2 1 C3 4 1.440
Drug A Cycle 2 1 C4 4 0.278
Drug A Cycle 2 1 C3 5 1.180
Drug A Cycle 2 1 C4 5 0.234
Drug A Cycle 2 1 C3 6 1.360
Drug A Cycle 2 1 C4 6 0.281
Drug A Cycle 3 1 C3 7 1.190
Drug A Cycle 3 1 C4 7 0.282
Drug A Cycle 3 1 C3 8 1.000
Drug A Cycle 3 1 C4 8 0.228
Drug A Cycle 3 1 C3 9 1.040
Drug A Cycle 3 1 C4 9 0.228
Drug A Cycle 4 1 C3 10 0.917
Drug A Cycle 4 1 C4 10 0.163
Drug A Cycle 4 1 C3 11 0.789
Drug A Cycle 4 1 C4 11 0.136
Drug A Cycle 4 1 C3 12 0.861
Drug A Cycle 4 1 C4 12 0.148
Drug A Cycle 1 2 C3 1 1.180
Drug A Cycle 1 2 C4 1 0.264
Drug A Cycle 1 2 C3 2 0.942
Drug A Cycle 1 2 C4 2 0.184
Drug A Cycle 1 2 C3 3 1.010
Drug A Cycle 1 2 C4 3 0.160
Drug A Cycle 2 2 C3 4 1.050
Drug A Cycle 2 2 C4 4 0.134
Drug A Cycle 2 2 C3 5 0.980
Drug A Cycle 2 2 C4 5 0.120
Drug A Cycle 2 2 C3 6 1.020
Drug A Cycle 2 2 C4 6 0.126
Drug A Cycle 3 2 C3 7 0.961
Drug A Cycle 3 2 C4 7 0.110
Drug A Cycle 3 2 C3 8 0.859
Drug A Cycle 3 2 C4 8 0.091
Drug A Cycle 3 2 C3 9 0.928
Drug A Cycle 3 2 C4 9 0.097
Drug A Cycle 4 2 C3 10 1.380
Drug A Cycle 4 2 C4 10 0.330
Drug A Cycle 4 2 C3 11 1.210
Drug A Cycle 4 2 C4 11 0.281
Drug A Cycle 4 2 C3 12 1.180
Drug A Cycle 4 2 C4 12 0.278
Drug A Cycle 1 3 C3 1 1.180
Drug A Cycle 1 3 C4 1 0.269
Drug A Cycle 1 3 C3 2 1.010
Drug A Cycle 1 3 C4 2 0.213
Drug A Cycle 1 3 C3 3 1.040
Drug A Cycle 1 3 C4 3 0.200
Drug A Cycle 2 3 C3 4 1.200
Drug A Cycle 2 3 C4 4 0.332
Drug A Cycle 2 3 C4 5 0.371
Drug A Cycle 2 3 C4 6 0.316
Drug A Cycle 3 3 C4 7 0.271
Drug A Cycle 3 3 C3 8 1.050
Drug A Cycle 3 3 C4 8 0.246
Drug A Cycle 3 3 C3 9 1.100
Drug A Cycle 3 3 C4 9 0.248
Drug A Cycle 4 3 C3 10 1.090
Drug A Cycle 4 3 C4 10 0.234
Drug A Cycle 4 3 C3 11 0.937
Drug A Cycle 4 3 C3 12 0.980
Drug A Cycle 1 4 C3 1 1.220
Drug A Cycle 1 4 C4 1 0.182
Drug A Cycle 1 4 C3 2 0.983
Drug A Cycle 1 4 C4 2 0.132
Drug A Cycle 1 4 C3 3 0.979
Drug A Cycle 1 4 C4 3 0.128
Drug A Cycle 2 4 C3 4 1.190
Drug A Cycle 2 4 C4 4 0.134
Drug A Cycle 2 4 C3 5 1.010
Drug A Cycle 2 4 C4 5 0.076
Drug A Cycle 2 4 C3 6 1.100
Drug A Cycle 2 4 C4 6 0.083
Drug A Cycle 3 4 C3 7 1.140
Drug A Cycle 3 4 C4 7 0.108
Drug A Cycle 3 4 C3 8 1.140
Drug A Cycle 3 4 C4 8 0.104
Drug A Cycle 3 4 C3 9 1.120
Drug A Cycle 3 4 C4 9 0.080
;
run;
proc sort data=immune out=sasuser.immune;
by pt;
run;
data firstrow;
length ROW $20 TITLE $20 REASON $50 CHAR $20 VAR $20;
infile datalines dlm=',';
input ROW TITLE REASON CHAR VAR;
datalines;
ROW 1,ROW 1,FIRST REASON,FIRST ROW,FIRST VAR,
ROW 2,ROW 2,SECOND REASON,SECOND ROW,SECOND VAR,
ROW 3,ROW 3,THIRD REASON,THIRD ROW,THIRD VAR,
ROW 4,ROW 4,FOURTH REASON,FOURTH ROW,FOURTH VAR,
;
proc transpose data=firstrow out=firstrow_;
by row;
var title reason char var;
run;
并将“否”与上一个数据集合并:
proc sort data=immune out=immune;
by pt;
run;
data immune;
merge immune firstrow_;
run;
然后修改proc模板,添加布局晶格和区块图
proc template;
define statgraph gsv00251;
begingraph / designwidth=7in designheight=4.5in;
entrytitle 'Immunology Profile by Treatment';
layout lattice / columns=1 rowweights=(.15 .85);
blockplot x=row block=col1 / class=_name_
datatransparency = .75
display=(outline fill values label)
name="stats" filltype=alternate
valuehalign=center
includemissingclass=false
labelattrs=GraphDataText valueattrs=GraphDataText ;
layout gridded;
layout datalattice rowvar=lbparm /
headerlabeldisplay=value includemissingclass=false
columnaxisopts=(label="Cycle Day" griddisplay=on type=discrete
discreteopts=(tickdisplaylist=
("0" "15" "30" "0" "15" "30" "0" "15" "30" "0" "15" "30"))
offsetmin = .03 offsetmax = .03)
rowaxisopts=(offsetmax=.1 label="Values Converted to SI Units "
griddisplay=on) rowdatarange=union;
layout prototype;
blockplot x=xval block=cyc / datatransparency = .75
display=(outline fill )
name="block" filltype=alternate;
seriesplot x=xval y=sival / group=pt index=pt name='a'
display=all lineattrs=(pattern=1 thickness=2)
markerattrs=(symbol=circlefilled size=8);
endlayout;
endlayout;
entry ' ';
discretelegend 'a' / title='Patient' across=8;
endlayout;
endlayout;
endgraph;
end;
run;
结果很好,但不是最不重要的,我的意思是,列轴与两个图不对齐,结果是发布的第一个图
基本上有两个问题:标题标签在右边,轴标签在左边。我怎样才能改变这个图,以获得正确的结果?轴对齐
因为我发布了很多代码,所以在这里您只能找到所有这些的最终版本
data immune;
format sival f6.3;
input trt $ 1-8 cyc $ 10-18 pt lbparm $ xval sival;
cards;
Drug A Cycle 1 1 C3 1 1.120
Drug A Cycle 1 1 C4 1 0.147
Drug A Cycle 1 1 C3 2 1.080
Drug A Cycle 1 1 C4 2 0.131
Drug A Cycle 1 1 C3 3 0.887
Drug A Cycle 1 1 C4 3 0.113
Drug A Cycle 2 1 C3 4 1.440
Drug A Cycle 2 1 C4 4 0.278
Drug A Cycle 2 1 C3 5 1.180
Drug A Cycle 2 1 C4 5 0.234
Drug A Cycle 2 1 C3 6 1.360
Drug A Cycle 2 1 C4 6 0.281
Drug A Cycle 3 1 C3 7 1.190
Drug A Cycle 3 1 C4 7 0.282
Drug A Cycle 3 1 C3 8 1.000
Drug A Cycle 3 1 C4 8 0.228
Drug A Cycle 3 1 C3 9 1.040
Drug A Cycle 3 1 C4 9 0.228
Drug A Cycle 4 1 C3 10 0.917
Drug A Cycle 4 1 C4 10 0.163
Drug A Cycle 4 1 C3 11 0.789
Drug A Cycle 4 1 C4 11 0.136
Drug A Cycle 4 1 C3 12 0.861
Drug A Cycle 4 1 C4 12 0.148
Drug A Cycle 1 2 C3 1 1.180
Drug A Cycle 1 2 C4 1 0.264
Drug A Cycle 1 2 C3 2 0.942
Drug A Cycle 1 2 C4 2 0.184
Drug A Cycle 1 2 C3 3 1.010
Drug A Cycle 1 2 C4 3 0.160
Drug A Cycle 2 2 C3 4 1.050
Drug A Cycle 2 2 C4 4 0.134
Drug A Cycle 2 2 C3 5 0.980
Drug A Cycle 2 2 C4 5 0.120
Drug A Cycle 2 2 C3 6 1.020
Drug A Cycle 2 2 C4 6 0.126
Drug A Cycle 3 2 C3 7 0.961
Drug A Cycle 3 2 C4 7 0.110
Drug A Cycle 3 2 C3 8 0.859
Drug A Cycle 3 2 C4 8 0.091
Drug A Cycle 3 2 C3 9 0.928
Drug A Cycle 3 2 C4 9 0.097
Drug A Cycle 4 2 C3 10 1.380
Drug A Cycle 4 2 C4 10 0.330
Drug A Cycle 4 2 C3 11 1.210
Drug A Cycle 4 2 C4 11 0.281
Drug A Cycle 4 2 C3 12 1.180
Drug A Cycle 4 2 C4 12 0.278
Drug A Cycle 1 3 C3 1 1.180
Drug A Cycle 1 3 C4 1 0.269
Drug A Cycle 1 3 C3 2 1.010
Drug A Cycle 1 3 C4 2 0.213
Drug A Cycle 1 3 C3 3 1.040
Drug A Cycle 1 3 C4 3 0.200
Drug A Cycle 2 3 C3 4 1.200
Drug A Cycle 2 3 C4 4 0.332
Drug A Cycle 2 3 C4 5 0.371
Drug A Cycle 2 3 C4 6 0.316
Drug A Cycle 3 3 C4 7 0.271
Drug A Cycle 3 3 C3 8 1.050
Drug A Cycle 3 3 C4 8 0.246
Drug A Cycle 3 3 C3 9 1.100
Drug A Cycle 3 3 C4 9 0.248
Drug A Cycle 4 3 C3 10 1.090
Drug A Cycle 4 3 C4 10 0.234
Drug A Cycle 4 3 C3 11 0.937
Drug A Cycle 4 3 C3 12 0.980
Drug A Cycle 1 4 C3 1 1.220
Drug A Cycle 1 4 C4 1 0.182
Drug A Cycle 1 4 C3 2 0.983
Drug A Cycle 1 4 C4 2 0.132
Drug A Cycle 1 4 C3 3 0.979
Drug A Cycle 1 4 C4 3 0.128
Drug A Cycle 2 4 C3 4 1.190
Drug A Cycle 2 4 C4 4 0.134
Drug A Cycle 2 4 C3 5 1.010
Drug A Cycle 2 4 C4 5 0.076
Drug A Cycle 2 4 C3 6 1.100
Drug A Cycle 2 4 C4 6 0.083
Drug A Cycle 3 4 C3 7 1.140
Drug A Cycle 3 4 C4 7 0.108
Drug A Cycle 3 4 C3 8 1.140
Drug A Cycle 3 4 C4 8 0.104
Drug A Cycle 3 4 C3 9 1.120
Drug A Cycle 3 4 C4 9 0.080
;
run;
data firstrow;
length ROW $20 TITLE $20 REASON $50 CHAR $20 VAR $20;
infile datalines dlm=',';
input ROW TITLE REASON CHAR VAR;
datalines;
ROW 1,ROW 1,FIRST REASON,FIRST ROW,FIRST VAR,
ROW 2,ROW 2,SECOND REASON,SECOND ROW,SECOND VAR,
ROW 3,ROW 3,THIRD REASON,THIRD ROW,THIRD VAR,
ROW 4,ROW 4,FOURTH REASON,FOURTH ROW,FOURTH VAR,
;
proc transpose data=firstrow out=firstrow_;
by row;
var title reason char var;
run;
proc sort data=immune out=immune;
by pt;
run;
data immune;
merge immune firstrow_;
run;
proc template;
define statgraph gsv00251;
begingraph / designwidth=7in designheight=4.5in;
entrytitle 'Immunology Profile by Treatment';
layout lattice / columns=1 rowweights=(.15 .85);
columnaxes;
columnaxis / display=(ticks tickvalues);
endcolumnaxes;
blockplot x=row block=col1 / class=_name_
datatransparency = .75
display=(outline fill values label)
name="stats" filltype=alternate
valuehalign=center
includemissingclass=false
labelattrs=GraphDataText valueattrs=GraphDataText ;
layout gridded;
layout datalattice rowvar=lbparm /
headerlabeldisplay=value includemissingclass=false
columnaxisopts=(label="Cycle Day" griddisplay=on type=discrete
discreteopts=(tickdisplaylist=
("0" "15" "30" "0" "15" "30" "0" "15" "30" "0" "15" "30"))
offsetmin = .03 offsetmax = .03)
rowaxisopts=(offsetmax=.1 label="Values Converted to SI Units "
griddisplay=on) rowdatarange=union;
layout prototype;
blockplot x=xval block=cyc / datatransparency = .75
display=(outline fill )
name="block" filltype=alternate;
seriesplot x=xval y=sival / group=pt index=pt name='a'
display=all lineattrs=(pattern=1 thickness=2)
markerattrs=(symbol=circlefilled size=8);
endlayout;
endlayout;
entry ' ';
discretelegend 'a' / title='Patient' across=8;
endlayout;
endlayout;
endgraph;
end;
run;
ods listing close;
ods html image_dpi=100 file='Immunology.html' path='.';
ods graphics / reset noborder width=600px height=400px
imagename='ClinicalHandout_Immunology' imagefmt=gif noscale;
proc sgrender data=immune template=gsv00251;
run;
ods html close;
ods listing;
来自sas社区的交叉帖子谢谢Sanjay。 对于块打印和DATAPANEL图形,使用带有单独单元格的外部布局晶格容器时,所包含打印的轴之间没有对齐。情节彼此不了解 面板中的区块图具有X=XVAL,而顶部的区块图具有X=ROW。这些是自变量。此外,顶部图形是独立的,不需要为下部的行标题保留空间 最好的方法是避免使用数据面板。使用一个具有三行的布局晶格。底部两行将具有“C3”和“C4”数据的系列图。可以使用表达式仅提取一个LBPARM值的数据。使用INSET或Rowwader放置类值。顶行将使用块图或AxisTable显示统计信息。确保x变量相同或相似
了解您使用的SAS版本非常有用。使用SAS 9.4M3会更容易。我有点忙,想弄明白这一点,不幸的是,也许其他人中的一个会——但你可能会在communities.SAS.com上更快地找到关于这个特定问题的答案,因为Sanjay和Dan H在大多数情况下都回答得很快,而且他们都非常擅长让你找到正确的答案。我认为这是可能的,但我只需要花一些时间来玩它。谢谢你,乔,我在社区中发布了交叉帖子,桑杰回答说,你,瑞克,桑杰,还有所有这些来自SAS的出色的人都很棒。谢谢。你能把答案也作为答案贴在这里吗?嗯@Joe,这不完全是一个答案,但作为答案添加了OK,但仍然不被认为是正确的。