proc sql;
create table CARS as
select *
from sashelp.cars
where Type = "SUV" or Type = "Sedan";
quit;
proc template;
define statgraph scatter;
begingraph / backgroundcolor=CXD1D0CE border=true borderattrs=(color=CXEDDA74 thickness=5);
entrytitle halign=left textattrs=(size=15pt) "Plot";
entrytitle halign=left textattrs=(size=12pt weight=normal) "Scatter Plot" / opaque=true backgroundcolor=CXFFFFFF;
layout datalattice rowvar=Type /
headerlabeldisplay=value rowheaders=left
rowaxisopts=(griddisplay=on gridattrs=(pattern=dash) display=(ticks tickvalues))
columnaxisopts=(griddisplay=on gridattrs=(pattern=dash) labelattrs=(size=12pt weight=normal))
headerbackgroundcolor=CXFFFFFF headerlabelattrs=(size=10pt weight=normal);
layout prototype;
scatterplot x=MPG_City y=Cylinders / markerattrs=(color=CXC11B17 symbol=circlefilled) name='a';
scatterplot x=MPG_City y=EngineSize / markerattrs=(color=CX57E964 symbol=circlefilled) name='b';
scatterplot x=MPG_City y=Horsepower / yaxis=y2 markerattrs=(color=CX2B65EC symbol=circlefilled) name='c';
endlayout;
sidebar / align=bottom;
discretelegend "a" "b" "c"/ border=false valueattrs=(size=11pt);
endsidebar;
endlayout;
endgraph;
end;
run;
proc sgrender data=CARS template=scatter;
run;
Hi All,
Here attached are my code and plot and I want to switch the order of panels, like "SUV" at the bottom and "Sedan" at the top. How to solve this issue?
Thanks!
On the LAYOUT DATALATTICE statement, say:
SORTORDER=(ROWVAR=DESCENDINGFORMATTED)
Hope this helps!
Dan
Thanks, Dan!
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.