BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Fara_I
Fluorite | Level 6

I am trying to overlay two sets of data (one for males and one for females) on one scatterplot, but I don't know how to do this. I will greatly appreciate any input you can provide me on this matter. This is the code I have so far, but it plots the two sets of data on separate plots, and I want to fix this. Thank you! 

 

CODE: 
DATA female;
INPUT mass rate;
cards;
36.1 995
54.6 1425
48.5 1396
42.0 1418
40.3 1189
33.1 913
42.4 1124
34.5 1052
51.1 1347
41.2 1204
;
DATA male;
INPUT m_mass m_rate;
cards;
62.0 1792
62.9 1666
47.4 1362
48.7 1614
51.9 1460
51.9 1867
46.9 1439
;
proc sgplot data=female;
scatter x=mass y=rate;
proc sgplot data=male;
scatter x= m_mass y= m_rate;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

MERGE the data sets and add a grouping variable. Then use the GROUP= option on the SCATTER statement:

 

data All;
set female(in=f) male(rename=(m_mass=mass m_rate=rate));
if f then 
sex = 'Female';
else 
sex = 'Male  ';
run;

proc sgplot data=All;
scatter x=mass y=rate / group=sex;
run;

View solution in original post

1 REPLY 1
Rick_SAS
SAS Super FREQ

MERGE the data sets and add a grouping variable. Then use the GROUP= option on the SCATTER statement:

 

data All;
set female(in=f) male(rename=(m_mass=mass m_rate=rate));
if f then 
sex = 'Female';
else 
sex = 'Male  ';
run;

proc sgplot data=All;
scatter x=mass y=rate / group=sex;
run;