BookmarkSubscribeRSS Feed
seeth001
Calcite | Level 5
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
5 REPLIES 5
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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
goladin
Calcite | Level 5
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
seeth001
Calcite | Level 5
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
GraphGuy
Meteorite | Level 14
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!
GraphGuy
Meteorite | Level 14
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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1047 views
  • 0 likes
  • 4 in conversation