Data visualization with SAS programming

Question on Series plot in SGPANEL

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 140
Accepted Solution

Question on Series plot in SGPANEL

I am working on ways to visualize series.  Using the SASHELP.STOCKS data set, I am trying to panel by year. However, in the code below, the SERIES statement is linking December with the following January. I can't figure out how to fix this.

First, I create a new data set that has "month" separated for each year and decade created as well

data stocks;

set sashelp.stocks;

year = year(date);

month = mod(intck('MONTH', '01JAN1986'd, date), 12);

decade = floor(year/10);

run;

Next, I run the plot

proc sgpanel data = stocks;

panelby decade;

where stock = "IBM";

series x = month y = close;

run;

Resulting in the attached plot


Accepted Solutions
Solution
‎09-30-2013 12:49 PM
Grand Advisor
Posts: 9,743

Re: Question on Series plot in SGPANEL

try making year a group variable on the series statement.

View solution in original post


All Replies
Solution
‎09-30-2013 12:49 PM
Grand Advisor
Posts: 9,743

Re: Question on Series plot in SGPANEL

try making year a group variable on the series statement.

Frequent Contributor
Posts: 140

Re: Question on Series plot in SGPANEL

That worked perfectly!

Respected Advisor
Posts: 4,606

Re: Question on Series plot in SGPANEL

How about adding /GROUP=year in the series statement ?

PG

PG
Post a Question
Discussion Stats
  • 3 replies
  • 338 views
  • 5 likes
  • 3 in conversation