BookmarkSubscribeRSS Feed
mitrakos
Obsidian | Level 7

Hi Everyone,

 

I have some data I'm trying to plot but I'm at a crossroads as to how to. Here is a sample of it:

data sample;
input ID time mean test_q1 test_q2 test_q3 group_q1 $ group_q2 $ group_q3 $;
datalines;
1 1 5.44 0 0 1 A A A
1 2 3.59 0 0 1 A A A
1 3 2.33 0 0 1 A A A
2 1 1.45 1 1 1 A A A
2 2 5.66 1 1 1 A A A
2 3 7.65 1 1 1 A A A
3 1 2.34 2 1 1 A A A
3 2 4.54 2 1 1 A A A
3 3 3.76 2 1 1 A A A
4 1 8.76 3 2 2 B B B
4 2 9.45 3 2 2 B B B
4 3 2.34 3 2 2 B B B
5 1 5.55 4 4 4 B B B 
5 2 2.89 4 4 4 B B B 
5 3 7.44 4 4 4 B B B
;
run;

As you can see, it is repeated measures data. I am trying to do proc sgplot where x = time and y = mean, and generate a graph for each question based on the grouping variable for each question. Since it is repeated measures I need to specify it is by each ID, but I also want to group using the grouping variables. I'm not sure how to do about this as I don't think proc sgplot allows multiple grouping variables. 

 

Any idea on how to go about this? Any help is appreciated, thanks! 

2 REPLIES 2
ballardw
Super User

One strongly suspects your description is incomplete. You can use as many groups as you want. The behavior may not be what you expect. By default your legend will likely be incomplete.

 

proc sgplot data=sample;
   scatter x=time y=mean / group= group_q1 name='q1';
   scatter x=time y=mean / group= group_q2 name='q2';
   scatter x=time y=mean / group= group_q3 name='q3';
   keylegend 'q1' 'q2' 'q3';
run;

To incorporate TWO values, which is what I think you mean by ID and Group, then you must create one variable that will show both.

Or maybe us Proc Sgpanel with the Group_q variable(s) as PanelBy variables.

I am not sure what you expect this graph to look like. If you can draw one then we may be able to help.

 

I don't understand how your Test_Q variables fit in at all.

Rick_SAS
SAS Super FREQ

If your goal is to combine the joint levels of two (or more) categorical variables, then consider using the CATX function as shown in the section "Concatenate values to form joint levels of categories" in the article, "Visualize an ANOVA with two-way interactions." The article shows how to use CATX to combine the levels and PROC FORMAT to provide labels for the joint levels.

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2251 views
  • 0 likes
  • 3 in conversation