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: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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