BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
thanksforhelp12
Calcite | Level 5

I am trying to graph the results of a freq procedure output group*year.

 

I have a list of variables in a group column (group 1, group 2, group 3, etc.) I would like these to be the series.

Column 2 is a year variable 2000, 2001, 2002, etc.

Column 3 is the PCT_COL from the output of the freq procedure.

 

I would like to graph trends over time of Y value (PCT_COL) with X value being year and the different series being the groups 1, 2, 3. etc. in column 1. Is there some way to do this. I have searched and searched and just can't seem to even find the right search terms.

 

Basically would like to graph  SERIES X = Year Y = PCT_COL 

BY Group.

 

Thanks!!

 

1 ACCEPTED SOLUTION

Accepted Solutions
9 REPLIES 9
Reeza
Super User
GROUP option on the SERIES statement.
thanksforhelp12
Calcite | Level 5

Amazing, this is almost exactly the answer.


Does this make you have to have the same markers for all the points. I couldn't figure out how to change the markers between the specific groups

Reeza
Super User
Markers are default, to specify them and/or other line features I recommend the discrete attribute map. The documentation has some good examples.
thanksforhelp12
Calcite | Level 5

Thanks I will read into this. SAS seems to have the most unintuitive graphing language I've ever seen.

Have spent half the day trying to alter the thickness of the border of the graph part itself and the figure without any progress.

ballardw
Super User

This is another approach though the discrete attribute map option would be data order independent.

proc sgplot data=sashelp.class;
   title "Default markers";
   scatter x=height y=weight/group=age;
run;

proc sgplot data=sashelp.class;
   title "Style overide markers";
   styleattrs
      datacontrastcolors =(pink red darkred lightgreen green darkgreen)
      datasymbols=(circlefilled diamondfilled homedownfilled tack triangle plus)
   ;
   scatter x=height y=weight/group=age;
run;
proc sort data=sashelp.class out=work.class;
  by descending age sex;
run;
proc sgplot data=work.class;
    title "Style overide markers with different data order";
  styleattrs
      datacontrastcolors =(pink red darkred lightgreen green darkgreen)
      datasymbols=(circlefilled diamondfilled homedownfilled tack triangle plus)
   ;
   scatter x=height y=weight/group=age;
run;   title;

I used a scatter plot as I know the SASHELP.Class data set well enough to play with.

Series would also have the styleattrs for lines datalinepatterns.

LOTS of graphic options.

Reeza
Super User
Biggest difference between using Style Attributes and Attribute Maps is Attribute maps ensure the same variable value has the same colours/markers across multiple graphs. This is important because if you have a missing record for one group in one dataset/graph, the atttributes are selected in order so it may not always match. Ergo, I default to using attribute maps because it's safer.
ballardw
Super User

@Reeza wrote:
Biggest difference between using Style Attributes and Attribute Maps is Attribute maps ensure the same variable value has the same colours/markers across multiple graphs. This is important because if you have a missing record for one group in one dataset/graph, the atttributes are selected in order so it may not always match. Ergo, I default to using attribute maps because it's safer.

Which is why I supplied an example where the result changes based on data order and mentioned that as a potential issue.

But sometimes we only need one graph quickly and I haven't really got a good way to make a quick DATTRMAP set for that case.

Reeza
Super User


Fair enough, I didn't run the code. 

I found this statement ambiguous though: 

This is another approach though the discrete attribute map option would be data order independent.

 

Independent of data order would probably be more clear?

ballardw
Super User

@thanksforhelp12 wrote:

I am trying to graph the results of a freq procedure output group*year.

 

I have a list of variables in a group column (group 1, group 2, group 3, etc.) I would like these to be the series.

Column 2 is a year variable 2000, 2001, 2002, etc.

Column 3 is the PCT_COL from the output of the freq procedure.

 

I would like to graph trends over time of Y value (PCT_COL) with X value being year and the different series being the groups 1, 2, 3. etc. in column 1. Is there some way to do this. I have searched and searched and just can't seem to even find the right search terms.

 

Basically would like to graph  SERIES X = Year Y = PCT_COL 

BY Group.

 

Thanks!!

 


Have you created a data set from Proc freq output?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 9 replies
  • 1316 views
  • 4 likes
  • 3 in conversation