- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 07-01-2020 05:01 PM
(4721 views)
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
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
That's a really interesting question...I have no idea. To be safe you could set the random seed ahead of time anyways but I'm curious as to what the official answer will be, I'll move your question to the graphics forum. Hopefully that gets you an answer.
You can set your random seed using
call streaminit(99);
You can set your random seed using
call streaminit(99);
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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. */