BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sschiro
Fluorite | Level 6

I'm trying to generate a scatter plot inwhich I can set the axis crossing point.  The code I've tried so far is:

proc sgplot data=pi.LdIcuHospState;
where groupid=1 and year(edarrivaldate)=2015 and FacilityIDo ne "State";
title '2015 Survival Group 1';
scatter x=IssAvg_Ldr y=LiveDieAvgr  / group=FacilityIdo xorigin=&y_LD_Avg yorigin=&y_LD_Avg;
run;

 

But - I get an error message when I use the xorigin and yorigin statements. 

ERROR 22-322: Syntax error, expecting one of the following: ;, ATTRID, CLUSTERWIDTH, COLORMODEL,
              COLORRESPONSE, DATALABEL, DATALABELATTRS, DATALABELPOS, DATASKIN, DISCRETEOFFSET,
              ERRORBARATTRS, FILLEDOUTLINEDMARKERS, FREQ, GROUP, GROUPDISPLAY, GROUPORDER,
              JITTER, JITTERWIDTH, LABELSTRIP, LEGENDLABEL, MARKERATTRS, MARKERCHAR,
              MARKERCHARATTRS, MARKERFILLATTRS, MARKEROUTLINEATTRS, NAME, NOERRORCAPS,
              NOMISSINGGROUP, RATTRID, SPLITCHAR, SPLITCHARNODROP, SPLITJUSTIFY, TIP, TIPFORMAT,
              TIPLABEL, TRANSPARENCY, URL, X2AXIS, XERRORLOWER, XERRORUPPER, Y2AXIS, YERRORLOWER,
              YERRORUPPER.
ERROR 76-322: Syntax error, statement will be ignored

 

 

I'd like the output graph to look like the picture below.

 

GraphPicture2.jpg.

 

 

Suggestions?  Thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

The documentation of the SCATTER statement is here. Notice there are no XORIGIN or YORIGIN statements.

 

What you propose is not simple to do.  When I want to indicate an average value or some other reference value, I use the REFLINE statement to add vertical and horizontal reference lines, like this:

 

%let x_ave =  62.3;
%let y_ave = 100;

proc sgplot data=sashelp.class;
format Name $2.;
scatter x=Height y=Weight / datalabel=Name;
refline &x_ave / axis=x;
refline &y_ave / axis=y;
xaxis grid;
yaxis grid;
run;

View solution in original post

4 REPLIES 4
Rick_SAS
SAS Super FREQ

The documentation of the SCATTER statement is here. Notice there are no XORIGIN or YORIGIN statements.

 

What you propose is not simple to do.  When I want to indicate an average value or some other reference value, I use the REFLINE statement to add vertical and horizontal reference lines, like this:

 

%let x_ave =  62.3;
%let y_ave = 100;

proc sgplot data=sashelp.class;
format Name $2.;
scatter x=Height y=Weight / datalabel=Name;
refline &x_ave / axis=x;
refline &y_ave / axis=y;
xaxis grid;
yaxis grid;
run;
DanH_sas
SAS Super FREQ

It is possible to do this using GTL; however, if you want to stick with the SG procedures, I agree with RIck that using REFLINEs can give you a good display of this information. It also keeps the tick values out of the way of the data.

 

The SGPlot Procedure

 

%let x_avg=13.4;
%let y_avg=61.2;

proc sgplot data=sashelp.class noborder;
xaxis display=(noticks noline) grid;
yaxis display=(noticks noline) grid;
refline &x_avg / axis=x lineattrs=(thickness=3) label;
refline &y_avg / lineattrs=(thickness=3) label;
scatter x=age y=height / datalabel
        markerattrs=(symbol=circlefilled);
run;
sschiro
Fluorite | Level 6

Thanks! 

Jay54
Meteorite | Level 14

Cartesean axes are supported in GTL.  You can use the ORIGIN option in the LINEAROPTS of the XAXISOPTS and YAXISOPTS.  This is not supported in SGPLOT.  You can use the TMPLOUT option on the SGPLOT procedure to write out the GTL generated by the SGPLOT procedure for your code.  Then, you can read in the GTL, and add the ORIGIN= optiion in the XAXISOPTS and YAXISOPTS bundles to get what you want.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2677 views
  • 2 likes
  • 4 in conversation