BookmarkSubscribeRSS Feed
SASSLICK001
Obsidian | Level 7

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 "&param" / 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 &param +/- 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;

4 REPLIES 4
DR_Majeti
Quartz | Level 8

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

SASSLICK001
Obsidian | Level 7

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...

Jay54
Meteorite | Level 14

Can you provide the full code and sample data to run the program?

SASSLICK001
Obsidian | Level 7
PARAMCDPARAMtrta1SEQVISITn1mean1stderr1high1low1trta2n2mean2stderr2high2low2
TESTCDTestDRUG A1Day 115118.44443.90552122.35114.5389DRUG B15109.52.958968112.459106.541
TESTCDTestDRUG A2Day 215114.22224.112237118.3345110.11DRUG B15107.752.296654110.0467105.4533
TESTCDTestDRUG A3Day 3151174.368447121.3684112.6316DRUG B15111.52.692582114.1926108.8074
TESTCDTestDRUG A4Day 415120.11115.078398125.1895115.0327DRUG B15115.16673.161878118.3285112.0048
TESTCDTestDRUG A5Day 515115.33332.44949117.7828112.8838DRUG B15111.41673.583333115107.8333
TESTCDTestDRUG A6Day 615115.77784.875613120.6534110.9022DRUG B15110.252.46836112.7184107.7816
TESTCDTestDRUG A7Day 715112.11114.21454116.3257107.8966DRUG B15107.33332.422537109.7559104.9108
TESTCDTestDRUG A8Day 8151154.546061119.5461110.4539DRUG B15108.52.053542110.5535106.4465
TESTCDTestDRUG A9Day 915112.55564.343293116.8988108.2123DRUG B15107.71433.263903110.9782104.4504
TESTCDTestDRUG A10Day 10151204.734624124.7346115.2654DRUG B15117.92864.253588122.1822113.675
TESTCDTestDRUG A11Day 11151154.898979119.899110.101DRUG B15112.53.562241116.0622108.9378
TESTCDTestDRUG A12Day 1215115.55564.687783120.2433110.8678DRUG B15113.53.735411117.2354109.7646
TESTCDTestDRUG A13Day 1315109.22223.035795112.258106.1864DRUG B15109.21432.568145111.7824106.6461
TESTCDTestDRUG A14Day 1415110.66674.705198115.3719105.9615DRUG B15110.64292.873921113.5168107.7689
TESTCDTestDRUG A15Day 15151144.487637118.4876109.5124DRUG B15110.85713.60838114.4655107.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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 4 replies
  • 1174 views
  • 0 likes
  • 3 in conversation