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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 1529 views
  • 0 likes
  • 3 in conversation