Data visualization with SAS programming

proc sgscatter drawing lines in multiple graphs

Reply
New Contributor
Posts: 4

proc sgscatter drawing lines in multiple graphs

Hi,

I am a user new to sas as well as this forum. I am trying to create scatterplots in sas using PROC SGSCATTER to generate scatterplots (of groups male and female) of variable X against variables Y1, Y3, Y4, and Y5.

Following is my code:

ods listing gpath='C:\';

ods graphics / reset height=4.5in width=8.925in imagefmt=png imagename="img1";

proc sgscatter data=test;

  plot Y1*X  Y3*X Y4*X Y5*X /group=gender rows=2 columns=3 ;

run;

ods listing close;

The above produces an image file with 3 plots in the first row and 1 plot in the second row. However, I am having difficulty in drawing a straight line passing through the origin in each of the 4 plots.Is there any way I can extend this code so that a straight line passing through the origin appears in each of my plots? I tried using the sganno option that included a 'line' function, but it does nto seem to help. I would appreciate any useful input.  Thanks.

This is how my image looks:


img1.png
Super User
Posts: 11,105

Re: proc sgscatter drawing lines in multiple graphs

Try adding the option:

pbspline=(degree=1)

New Contributor
Posts: 4

Re: proc sgscatter drawing lines in multiple graphs

Thanks for your response. I am getting this warning message.

WARNING: X=PBSPLINE_X_Y5_GROUP_SORT_G__X is invalid. The option expects at least one non-missing value in the column.

However, this results in each plot with 2 different line for each gender group. I was just trying to insert a single line that that connects the points, say, (0,0) to (100,100) in each of the plots.

Super User
Posts: 11,105

Re: proc sgscatter drawing lines in multiple graphs

What did your annotate set look like when you tried the SGANNO approach?

New Contributor
Posts: 4

Re: proc sgscatter drawing lines in multiple graphs

I used this:

data linedata;

  function="line";

  drawspace="graphpercent";

  x1=0; y1=0; x2=100; y2=100;

    linethickness=1;

run;

I used the above dataset with the sganno option.

this creates a 45 degree line across the entire page, not the individual plots.

Ask a Question
Discussion stats
  • 4 replies
  • 632 views
  • 0 likes
  • 2 in conversation