BookmarkSubscribeRSS Feed
mcmaxwell
Fluorite | Level 6

For my current research I am giving undergraduate students within a particular course a survey to measure motivation at four points throughout the semester. This survey measures five motivational constructs (SE, TV, IGO, EGO, and CLB). I would like to create a line graph to visualize the change in motivation for each construct throughout the semester. I would also like to group the data by other variables (such as sex, ethnicity, etc.) to see if there are different trends for different subgroups within the population. 

My data is saved as a csv file which I then upload to SAS. I am using student ID number (SUID) as the identifier, and each time the students complete the motivation survey the data goes in a new column, organized by SUID.  Below is a snip of my data to show how it is organized. 

Capture.PNG

 

SE1_A is the motivation score for the first timepoint, while SE2_A is the motivation score for the second timepoint. So, for example, I would like to make a line plot showing how students scores change between SE1_A and SE2_A. I would like to make this plot showing the trend for each individual student, as well as average trends for groups of students (for example grouping by the variable cPLTL or URM). 

How do I do this?? Is there a better way for me to organize my data for doing this? Is there a way to make line plots with my data the way it is already organized? Any tips or SAS code would be greatly appreciated! Thanks in advance! 

2 REPLIES 2
ballardw
Super User

@mcmaxwell wrote:

For my current research I am giving undergraduate students within a particular course a survey to measure motivation at four points throughout the semester. This survey measures five motivational constructs (SE, TV, IGO, EGO, and CLB). I would like to create a line graph to visualize the change in motivation for each construct throughout the semester. I would also like to group the data by other variables (such as sex, ethnicity, etc.) to see if there are different trends for different subgroups within the population. 

My data is saved as a csv file which I then upload to SAS. I am using student ID number (SUID) as the identifier, and each time the students complete the motivation survey the data goes in a new column, organized by SUID.  Below is a snip of my data to show how it is organized. 


 

You would do better to have a variable, such as the date of the measure with an appropriate SAS date format and have the data organized as

SUID Date construct Value

And hopefully have a way to link in other characteristics of interest such as sex, age, ethnicity.

 

 

For individual students then your data would be easy to graph. Sort by SUID if want a single graph per student

 

proc sgplot data=yourdata;
   by SUID;
   series x=date y=value / group=construct
   ;
run;

or to have all students graphed together for the same construct

proc sgplot data=yourdata;
   by construct;
   series x=date y=value / group=suid
   ;
run;

Likely to be pretty busy and man want to use the KEYLEGEND to suppress a  legend.

 

 

 

 

Depending on what you want with the groups of students you could use one of the procedures like Proc Means/summary to summarize the values with Date Construct and the demographic characteristics as CLASS variables and request things like mean, max, min, median or what ever.

Use the summary data to plot.

For a simple series plot still use your date for an x variable but the summary statistic would be the y value, group would be the demographic variable.

You could overlay multiple statistics to show max and min along with the mean (or median). Or use a band plot to create highlighted area within the max and min (or other variable) values.

 

Or use the Date as a category variable with a VBOX and measure as the analysis variable and construct as as group variable with the full data to see more information about the distribution of values.

If multiple constructs are too busy you might move to SGPANEL and use construct and/or a demographic as the PANELBY variable(s) to get multiple similar charts.

 

A big advantage of using the actual date is that you could do things comparing the next years data moderately directly. Changing formats on a date variable will create different groups. So if you have your students with the actual dates different but all in the same month then using a format like YYMON. or YYMMN. would treat all the surveys as the same time period.

 

Your  current data structure would have to be transposed to have any chance of graphs as I understand what you want. You would have to parsing your variable names to get "time point 1". Not difficult but

 

\

mcmaxwell
Fluorite | Level 6

Thank you, that is very helpful! 

 

Do you have any recommendations on how to restructure my data as SUID Date Construct and Value as the columns? I have about 450 observations for the first timepoint and around 300 for the second, so converting manually is not an option. It seems to me that I need to figure out how to flip the motivation columns to be rows and add rows so that each student has 5 rows, one for each construct. 

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