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!
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.