Turn on suggestions

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

Showing results for

- Home
- /
- Programming
- /
- Graphics
- /
- Trend Analysis

Options

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 11-05-2010 10:35 AM
(883 views)

I have been trying to work on plotting some graphs using sas. But I cannot seem to figure this time series graph with frequency on the y-axis.

My dataset contains the following variables.

1. Year (Years 1990 – 2010)

2. Term ( 3 categories)

3. Class (4 categories)

I need Year on the Y-axis and Term as a group and class as a subgroup. I would kinda like to see a trend in frequency (something similar to trend analysis).

Any Thoughts?

Thanks

My dataset contains the following variables.

1. Year (Years 1990 – 2010)

2. Term ( 3 categories)

3. Class (4 categories)

I need Year on the Y-axis and Term as a group and class as a subgroup. I would kinda like to see a trend in frequency (something similar to trend analysis).

Any Thoughts?

Thanks

5 REPLIES 5

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Suggest you start with contributing what SAS code you have been working with, thus far, for specific reference and feedback. Also, suggest contributing some sample "input" and "output" (how it would summarize/group) data examples to help with referencing your specific rqmts.

Scott Barry

SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

gchart group subgroup +"time series" data site:sas.com

Scott Barry

SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

gchart group subgroup +"time series" data site:sas.com

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hi,

A quick check indicate the gbarline as a possible candidate for you.

Another alternative is to use proc gplot. Given that you do not need barcharts, you can use term and class to form a categorical term and subsequently create a full time series plot using overlay.

Below is an example.

DATA TEMP;

DO I = 1 TO 1000;

YEAR = INT(RANUNI(12345)*10+1990);

CAT = INT(RANUNI(12345)*3+1);

CAT2 = INT(RANUNI(12345)*4+1);

OUTPUT;

END;

RUN;

PROC SQL;

CREATE TABLE TEMP AS SELECT YEAR AS YEAR, CAT AS CAT ,CAT2 AS CAT2 ,COUNT(*) AS TOTAL FROM TEMP GROUP BY YEAR,CAT,CAT2;

QUIT;

SYMBOL1 INTERPOL=L;

DATA TEMP;

SET TEMP;

GROUP = COMPRESS(CAT||CAT2);

RUN;

PROC GPLOT DATA=TEMP;

PLOT TOTAL*YEAR=GROUP / OVERLAY;

RUN;

QUIT;

Just my 2 cents ranting.

Regards,

Murphy

A quick check indicate the gbarline as a possible candidate for you.

Another alternative is to use proc gplot. Given that you do not need barcharts, you can use term and class to form a categorical term and subsequently create a full time series plot using overlay.

Below is an example.

DATA TEMP;

DO I = 1 TO 1000;

YEAR = INT(RANUNI(12345)*10+1990);

CAT = INT(RANUNI(12345)*3+1);

CAT2 = INT(RANUNI(12345)*4+1);

OUTPUT;

END;

RUN;

PROC SQL;

CREATE TABLE TEMP AS SELECT YEAR AS YEAR, CAT AS CAT ,CAT2 AS CAT2 ,COUNT(*) AS TOTAL FROM TEMP GROUP BY YEAR,CAT,CAT2;

QUIT;

SYMBOL1 INTERPOL=L;

DATA TEMP;

SET TEMP;

GROUP = COMPRESS(CAT||CAT2);

RUN;

PROC GPLOT DATA=TEMP;

PLOT TOTAL*YEAR=GROUP / OVERLAY;

RUN;

QUIT;

Just my 2 cents ranting.

Regards,

Murphy

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thanks for that,

I am trying to plot this graph and been having very small problems. This is what my code looks like

title1 h=2.00 f='Georgia' j=C

'';

title3 h=2.00 f='Georgia' j=c' ';

footnote j=right ' ';

axis1 label=YEAR major=none minor=none style=0 value=(h=0.75);

axis2 label=ENROLLMENT major=(c=CXFFFFFF); /* make major ticks invisible */

symbol1 v=none i=join w=1.5 c=CX9900CC pointlabel= (h=0.85) ;

symbol2 v=none i=none r=2.5; /* no symbols/lines for PLOT2 */

proc gplot data=perm.freq_Year;

plot Total*STYEAR /

haxis=axis1 /* axis1 statement defines the horizontal axis */

vaxis=axis2 /* axis2 statement defines the vertical axis */

/*autovref /* reference lines at major y-axis tick marks */

lvref=33 ; /* line type 33 for reference lines */

plot2 Total*STYEAR=1; /* to get the right-hand vertical axis */

run; quit;

The problem am having is with pointlabel. I am getting pointlabel 2 times at every data point.

Thanks

I am trying to plot this graph and been having very small problems. This is what my code looks like

title1 h=2.00 f='Georgia' j=C

'';

title3 h=2.00 f='Georgia' j=c' ';

footnote j=right ' ';

axis1 label=YEAR major=none minor=none style=0 value=(h=0.75);

axis2 label=ENROLLMENT major=(c=CXFFFFFF); /* make major ticks invisible */

symbol1 v=none i=join w=1.5 c=CX9900CC pointlabel= (h=0.85) ;

symbol2 v=none i=none r=2.5; /* no symbols/lines for PLOT2 */

proc gplot data=perm.freq_Year;

plot Total*STYEAR /

haxis=axis1 /* axis1 statement defines the horizontal axis */

vaxis=axis2 /* axis2 statement defines the vertical axis */

/*autovref /* reference lines at major y-axis tick marks */

lvref=33 ; /* line type 33 for reference lines */

plot2 Total*STYEAR=1; /* to get the right-hand vertical axis */

run; quit;

The problem am having is with pointlabel. I am getting pointlabel 2 times at every data point.

Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

I would suspect that if you're getting 2 pointlabels at each gplot marker, you might have 2 obsns in your data set with the same x/y values.

Have a look at your data (proc print, or the SAS table viewer) and let us know if that's the case!

Have a look at your data (proc print, or the SAS table viewer) and let us know if that's the case!

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Ahh! - Looking at your code more closely, I think I see the problem...

I think your first "plot" statement uses uses symbol1 (since you don't specify which symbol statement), and in your second plot statement "plot2" you specify y*x=1 (therefore it uses symbol1. Since symbol1 says to do a pointlabel, and since both plot and plot2 use symbol1, you get 2 pointlabels.

I think your first "plot" statement uses uses symbol1 (since you don't specify which symbol statement), and in your second plot statement "plot2" you specify y*x=1 (therefore it uses symbol1. Since symbol1 says to do a pointlabel, and since both plot and plot2 use symbol1, you get 2 pointlabels.

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.