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:
Try adding the option:
pbspline=(degree=1)
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.
What did your annotate set look like when you tried the SGANNO approach?
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.
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.
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.