BookmarkSubscribeRSS Feed
jamie2
Calcite | Level 5

Using SAS 9.4, I employ SGPLOT to produce two SCATTERs on the same output: one plotting subject values on YAXIS (blue), the other plotting the same set of subjects values on Y2AXIS (red).

I want to draw a line (purple) from a particular subject’s values on one box to their value on the other box.

Can you point me in the right direction?
Pun intended. 

I imagine that I need to transform the Y2 values so that they map to Y1 values and then draw lines using SGANNO as if the Y2 axis does not exist.... 

1 REPLY 1
Reeza
Super User

One option is to do some math to figure out the equation of your line and use a LINEPARM statement.

 

https://documentation.sas.com/?docsetId=grstatproc&docsetVersion=9.4&docsetTarget=n1h6n82pw2uqo6n10a...

 

Or add it in as second set of data in new variables and use a SERIES statement with GROUP to get the dots connected. 

That's probably the easiest way. If you can provide raw data used to generate that graph and your current code someone can help with the code.

 

Here are instructions on how to provide sample data as a data step:
https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

 


@jamie2 wrote:

Using SAS 9.4, I employ SGPLOT to produce two SCATTERs on the same output: one plotting subject values on YAXIS (blue), the other plotting the same set of subjects values on Y2AXIS (red).

I want to draw a line (purple) from a particular subject’s values on one box to their value on the other box.

Can you point me in the right direction?
Pun intended. 

I imagine that I need to transform the Y2 values so that they map to Y1 values and then draw lines using SGANNO as if the Y2 axis does not exist.... 


 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 411 views
  • 0 likes
  • 2 in conversation