how to create a 2d scatter plot using two data sets

Reply
New Contributor
Posts: 2

how to create a 2d scatter plot using two data sets

I need to create a 2D scatter plot using two data sets. Both data sets contain the same variables (x1, x2, x3, x4, x5, x6). Not sure how to do this.

I also need to create a 3d scatter plot again using both data sets but this time with just 3 of the variables (x4, x5, x6).

Any pointers on how to do this would be greatly appreciated!

Thank you,

M

Respected Advisor
Posts: 4,655

Re: how to create a 2d scatter plot using two data sets

SAS plotting procedures require a single input dataset. So, you will need to combine your two datasets somehow. Exactly how depends on your precise requirements. Please provide more details.

PG

PG
Regular Contributor
Posts: 244

Re: how to create a 2d scatter plot using two data sets

You don't really give us much to go on, do you?  What's the significance of the second data set?  What are you graphing - what's your x/y variables?

New Contributor
Posts: 2

Re: how to create a 2d scatter plot using two data sets

This is for a course I am taking and unfortunately, I have not been given much more information than what I have provided. I was given a .txt file with 200 observations and 6 variables (x1,x2,x3,x4,x5,x6). The instructions say to split the data set. The first 100 observations represent 1 set of measurements (genuine banknotes (XT)) the 2nd 100 observations represent (counterfeit banknotes (XF)). The second set of instructions say to construct a 2D scatter plot for XT vs XF of the bank notes. That is all the instructions I have. Sorry for the lack of info.

Regular Contributor
Posts: 244

Re: how to create a 2d scatter plot using two data sets

Sounds like x1-x6 are six data points where genuine and counterfeit banknotes might have differences.

Assuming you're taking the PSU course here, or one with a similar dataset, you need to input swiss3.txt, or set the two datasets together, with a new variable 'real' or 'fake' which differentiates which dataset they came from.

Then you could run any number of comparisons.  Here's one example.

proc sgscatter data=banknotes;

matrix x1-x6/group=type;

run;

A scatterplot matrix is a great way to see how variables interrelate.  You could use this in theory to identify which combinations of variables give you the best way to tell which note is fake or real.


scatter.png
Regular Contributor
Posts: 244

Re: how to create a 2d scatter plot using two data sets

Also, to answer your second question, look at PROC G3D for 3d scatterplots.  It's not an ODS Graphics procedure, so it won't necessarily work the same as SGSCATTER, but it is the only way I know of to do a 3d scatter plot.  You should use the Real vs Fake to determine the shape (look at the shape option on the scatter statement, using a variable to determine it).

Ask a Question
Discussion stats
  • 5 replies
  • 448 views
  • 0 likes
  • 3 in conversation