turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS/GRAPH and ODS Graphics
- /
- plotting two time series that shows alternatively ...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-12-2014 01:07 PM

I want to plot two time series and interpolate those points that show together. The two time series are part of one original series. The difficulty here is that the two time series shows up alternatively. For example, the first series may be from 8:30 to 9:30 then the second series show up from 9:30 to 10:30 and so on so forth. I only want to interpolate the points that belong to the same series and show up consecutively. Simply using symbol statement is problematic because it will interpolate all data points that belong to the same series altogether. I hope I make myself clear. Thank you for your help.

Accepted Solutions

Solution

09-12-2014
03:38 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-12-2014 03:38 PM

Here's how to do a graph similar to PG's, but using Proc Gplot ...

symbol1 value=dot interpol=join color=red;

symbol2 value=dot interpol=join color=blue;

proc gplot data=ex;

plot price1*time=1 price2*time=2 / overlay skipmiss;

run;

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-12-2014 01:17 PM

If you post some data, I or somebody else will show you how to do this with SGPLOT.

PG

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-12-2014 01:52 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-12-2014 02:24 PM

Your time series already have missing values. Is this what you need?

**data ex;**

**infile "&sasforum\datasets\example.txt" firstobs=2;**

**input Obs time :time10. price1 price2;**

**format time time10.;**

**run;**

**proc sgplot data=ex;**

**series x=time y=price1 / markers break lineattrs=(pattern=solid) markerattrs=(symbol=circle); **

**series x=time y=price2 / markers break lineattrs=(pattern=solid) markerattrs=(symbol=circle);**

**xaxis type=time;**

**run;**

PG

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-12-2014 03:33 PM

Thank you PG. That is what i need. But can i do it with proc gplot?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-12-2014 03:35 PM

PG, the missing value is because the two series used to belong one original series. The two are the two parts of one complete series.

Solution

09-12-2014
03:38 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-12-2014 03:38 PM

Here's how to do a graph similar to PG's, but using Proc Gplot ...

symbol1 value=dot interpol=join color=red;

symbol2 value=dot interpol=join color=blue;

proc gplot data=ex;

plot price1*time=1 price2*time=2 / overlay skipmiss;

run;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-12-2014 04:00 PM

Thank you Robert. I tried your code. It works. But I want to use interpol=steplj to link those points. Then it does not work. As you can see these are stock price series. The market is a limit order market where price lasts as long as it is not replaced with better ones.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-12-2014 04:06 PM

Ahh! - You didn't mention that before!

Per the Gplot documentation for the 'skipmiss' option:

SAS/GRAPH(R) 9.4: Reference, Third Edition

Unfortunately ... "The SKIPMISS option is available only with JOIN interpolation."

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-12-2014 04:08 PM

Sorry Robert, is there any possibility I can do this with interpol=steplj?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-12-2014 04:16 PM

Per PG's method, it is possible to do this with proc sgplot.

proc sgplot data=example;

step x=time y=price1/markers break;

step x=time y=price2/markers break;

title;

footnote;

run;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-12-2014 01:18 PM

You can use gplot's "skipmiss" option to accomplish this.

Just make sure there is at least 1 'missing value' between each section of the line where you want the break to be.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-12-2014 01:57 PM

Thank you Robert. Unfortunately, I have a huge amount of data. Inserting a missing data every time there is a alternation is too burdernsome. Is there any other way I can do this using gplot?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-12-2014 02:04 PM

also, Robert, I need to plot time series of two prices that show alternatively. The missing value you mentioned need to be the missing values of the price series. I don't know how i can insert missing value for these two series.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-12-2014 03:15 PM

When should there be a break in the line? (ie, what is the logic/criteria for making that decision?)