Hi all sas experts,
I have quick question about scatterplot with jitter. if the input data are same, the scatter plot with jitter's sas code is also same, the output plot shall be exacatly same (each point position exactly same position) when I run this code different times. correct?
Thanks,
Lee
A quick test (on my old version) shows that the randomisation algorithm is constant.
ods graphics on / width=320px height=200px;
data IRIS; set SASHELP.IRIS; where PETALLENGTH < 20;
proc sgplot data=IRIS; scatter x=PETALLENGTH y=PETALWIDTH/ jitter;
proc sgplot data=IRIS; scatter x=PETALLENGTH y=PETALWIDTH/ jitter;
proc sgplot data=IRIS; scatter x=PETALLENGTH y=PETALWIDTH/ jitter;
proc sgplot data=IRIS; scatter x=PETALLENGTH y=PETALWIDTH /jitter;
proc sgplot data=IRIS; scatter x=PETALLENGTH y=PETALWIDTH/ jitter;
run;
Is the picture visible below?
I believe that is correct. You can use ODS OUTPUT to save the underlying data to a SAS data set, then use PROC COMPARE to show that the values are the same:
data IRIS; set SASHELP.IRIS; where PETALLENGTH < 20;
run;
ods output sgplot =sg1;
proc sgplot data=IRIS;
scatter x=PETALLENGTH y=PETALWIDTH/ jitter jitterwidth=1;
xaxis grid;
yaxis grid;
run;
/* wait 3 seconds, just in case the seed is based on the time */
data _null_;
call sleep(3000);
run;
ods output sgplot =sg2;
proc sgplot data=IRIS;
scatter x=PETALLENGTH y=PETALWIDTH/ jitter jitterwidth=1;
xaxis grid;
yaxis grid;
run;
proc compare base=sg1 compare=sg2;
run;
/* RESULT: No unequal values were found. All values compared are exactly
equal. */
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.