BookmarkSubscribeRSS Feed
lyan1971
Calcite | Level 5

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
Reeza
Super User
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);

ChrisNZ
Tourmaline | Level 20

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?

ChrisNZ_0-1593657406032.png

 

 
 
 

 

 

 

 

Rick_SAS
SAS Super FREQ

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. */

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 3881 views
  • 4 likes
  • 4 in conversation