Hello All
I am trying to use axislegend statement as I have almost 30 ticks to be displayed on x-axis
the following is the code, but still its not plotting what i intend
proc template;
define statgraph plot1;
begingraph / designwidth=9.0in designheight=5.05in border=yes;
entrytitle "¶m" / textattrs=(size=9);
layout lattice / columndatarange=union rowweights=(0.95); ;
layout overlay /
xaxisopts=(name="xaxis" discreteopts=(tickvaluefitpolicy=extract) offsetmax=0.05 tickvalueattrs=(size=9pt) type=linear display=(line ticks tickvalues)
linearopts=(tickvaluefitpolicy=none tickvaluelist=(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33)
))
yaxisopts=(label="Mean of ¶m +/- SE" tickvalueattrs=(size=9pt)
linearopts=(tickvaluesequence=(start=&&ymin&i end=&&ymax&i increment=&&ytick&i) viewmin=&&ymin&i viewmax=&&ymax&i minorticks=true)
);
seriesplot x=eval(atptn-1*&offx) y=mean1/ lineattrs=graphdata1(pattern=solid thickness=1) name='1' legendlabel="Drug C";
scatterplot x=eval(atptn-1*&offx) y=mean1/ YErrorUpper=High1 YErrorLower=Low1
markerattrs=graphdata1(symbol=trianglefilled size=10) errorbarattrs=graphdata1(pattern=solid)
name='a' legendlabel="Drug C";
seriesplot x=eval(atptn) y=mean2 / lineattrs=graphdata2(pattern=shortdash thickness=1) name='2' legendlabel="Drug A";
scatterplot x=eval(atptn) y=mean2 / YErrorUpper=High2 YErrorLower=Low2
markerattrs=graphdata2(symbol=circlefilled size=8.5) errorbarattrs=graphdata2(pattern=solid)
name='b' legendlabel="Drug A";
seriesplot x=eval(atptn+1*&offx) y=mean3 / lineattrs=graphdata3(pattern=mediumdash thickness=1) name='3' legendlabel="Drug B";
scatterplot x=eval(atptn+1*&offx) y=mean3 / YErrorUpper=High3 YErrorLower=Low3
markerattrs=graphdata3(symbol=asterisk size=8.5) errorbarattrs=graphdata3(pattern=solid)
name='c' legendlabel="Drug B";
axislegend "xaxis" /location=outside;
endlayout;
sidebar / spacefill=false;
discretelegend 'a' 'b' 'c' / title='Treatment Group: ' across=3;
endsidebar;
endlayout;
endgraph;
end;
run;
Hi,
When you are using Lattice layout, the size allotted to particular plot will be very less.
In this case if you want to all the ticks decrease the size of font of tick marks [tickvalueattrs=(size=9pt)].
That is one of the possibility.
Please can you attach the output you are looking for.
Thanks
Even when the font size decreases the text might not be visible at all.
i Need an outside legend box 1= day 1 am dose, 2= day1 pm dose etc...
Can you provide the full code and sample data to run the program?
PARAMCD | PARAM | trta1 | SEQ | VISIT | n1 | mean1 | stderr1 | high1 | low1 | trta2 | n2 | mean2 | stderr2 | high2 | low2 |
TESTCD | Test | DRUG A | 1 | Day 1 | 15 | 118.4444 | 3.90552 | 122.35 | 114.5389 | DRUG B | 15 | 109.5 | 2.958968 | 112.459 | 106.541 |
TESTCD | Test | DRUG A | 2 | Day 2 | 15 | 114.2222 | 4.112237 | 118.3345 | 110.11 | DRUG B | 15 | 107.75 | 2.296654 | 110.0467 | 105.4533 |
TESTCD | Test | DRUG A | 3 | Day 3 | 15 | 117 | 4.368447 | 121.3684 | 112.6316 | DRUG B | 15 | 111.5 | 2.692582 | 114.1926 | 108.8074 |
TESTCD | Test | DRUG A | 4 | Day 4 | 15 | 120.1111 | 5.078398 | 125.1895 | 115.0327 | DRUG B | 15 | 115.1667 | 3.161878 | 118.3285 | 112.0048 |
TESTCD | Test | DRUG A | 5 | Day 5 | 15 | 115.3333 | 2.44949 | 117.7828 | 112.8838 | DRUG B | 15 | 111.4167 | 3.583333 | 115 | 107.8333 |
TESTCD | Test | DRUG A | 6 | Day 6 | 15 | 115.7778 | 4.875613 | 120.6534 | 110.9022 | DRUG B | 15 | 110.25 | 2.46836 | 112.7184 | 107.7816 |
TESTCD | Test | DRUG A | 7 | Day 7 | 15 | 112.1111 | 4.21454 | 116.3257 | 107.8966 | DRUG B | 15 | 107.3333 | 2.422537 | 109.7559 | 104.9108 |
TESTCD | Test | DRUG A | 8 | Day 8 | 15 | 115 | 4.546061 | 119.5461 | 110.4539 | DRUG B | 15 | 108.5 | 2.053542 | 110.5535 | 106.4465 |
TESTCD | Test | DRUG A | 9 | Day 9 | 15 | 112.5556 | 4.343293 | 116.8988 | 108.2123 | DRUG B | 15 | 107.7143 | 3.263903 | 110.9782 | 104.4504 |
TESTCD | Test | DRUG A | 10 | Day 10 | 15 | 120 | 4.734624 | 124.7346 | 115.2654 | DRUG B | 15 | 117.9286 | 4.253588 | 122.1822 | 113.675 |
TESTCD | Test | DRUG A | 11 | Day 11 | 15 | 115 | 4.898979 | 119.899 | 110.101 | DRUG B | 15 | 112.5 | 3.562241 | 116.0622 | 108.9378 |
TESTCD | Test | DRUG A | 12 | Day 12 | 15 | 115.5556 | 4.687783 | 120.2433 | 110.8678 | DRUG B | 15 | 113.5 | 3.735411 | 117.2354 | 109.7646 |
TESTCD | Test | DRUG A | 13 | Day 13 | 15 | 109.2222 | 3.035795 | 112.258 | 106.1864 | DRUG B | 15 | 109.2143 | 2.568145 | 111.7824 | 106.6461 |
TESTCD | Test | DRUG A | 14 | Day 14 | 15 | 110.6667 | 4.705198 | 115.3719 | 105.9615 | DRUG B | 15 | 110.6429 | 2.873921 | 113.5168 | 107.7689 |
TESTCD | Test | DRUG A | 15 | Day 15 | 15 | 114 | 4.487637 | 118.4876 | 109.5124 | DRUG B | 15 | 110.8571 | 3.60838 | 114.4655 | 107.2488 |
proc template;
define statgraph plot1;
begingraph / designwidth=9.0in designheight=5.05in border=yes;
entrytitle "test" / textattrs=(size=9);
layout lattice / columndatarange=union rowweights=(0.95 .04 .04 .04); ;
layout overlay /
xaxisopts=(name="xaxis" discreteopts=(tickvaluefitpolicy=extract) offsetmax=0.05 tickvalueattrs=(size=9pt) type=linear display=(line ticks tickvalues)
linearopts=(tickvaluefitpolicy=none tickvaluelist=(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 )
tickdisplaylist=('BL' 'Day 1' '' '' '' '' '' '' 'Day 8' '' '' '' '' 'Day 13' '' 'Day 15' )
))
yaxisopts=(label="Mean of test +/- SE" tickvalueattrs=(size=9pt)
linearopts=(tickvaluesequence=(start=100 end=135 increment=5) viewmin=100 viewmax=135 minorticks=true)
);
seriesplot x=eval(seq-1*0.05) y=mean1/ lineattrs=graphdata1(pattern=solid thickness=1) name='1' legendlabel="Drug A";
scatterplot x=eval(seq-1*0.05) y=mean1/ YErrorUpper=High1 YErrorLower=Low1
markerattrs=graphdata1(symbol=trianglefilled size=10) errorbarattrs=graphdata1(pattern=solid)
name='a' legendlabel="Drug A";
seriesplot x=eval(seq) y=mean2 / lineattrs=graphdata2(pattern=shortdash thickness=1) name='2' legendlabel="Drug B";
scatterplot x=eval(seq) y=mean2 / YErrorUpper=High2 YErrorLower=Low2
markerattrs=graphdata2(symbol=circlefilled size=8.5) errorbarattrs=graphdata2(pattern=solid)
name='b' legendlabel="Drug B";
axislegend "xaxis" /location=outside;
endlayout;
blockplot x=seq block=n1 /display=(values label) valuehalign=center label='Drug A'
repeatedvalues=true valueattrs=graphdata1 labelattrs=graphdata1;
blockplot x=seq block=n2 /display=(values label) valuehalign=center label='Drug B'
repeatedvalues=true valueattrs=graphdata2 labelattrs=graphdata2;
sidebar / spacefill=false;
discretelegend 'a' 'b' / title='Treatment Group: ' across=3;
endsidebar;
endlayout;
endgraph;
end;
run;
proc sgrender data=figure template=plot1;
run;
The above data can be pasted directly in the excel and create the dataset and i tried to modify the code as much as possible to run it for you,
Please excuse me if it doesnot straight forward , minor modfications shoudl able to run
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.