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.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.