This is my first time creating graphs in SAS and need some direction. How can I create a line graph for each patient below for score1? I want visits on the x-axis and score on the y-axis. There should be 3 lines representing each of the 3 patients on one graph.
Visit | Patient | score1 |
Week1 | 1 | 0 |
Week2 | 1 | 0.8 |
Week3 | 1 | 1.1 |
Week4 | 1 | 2 |
Week1 | 2 | 1 |
Week2 | 2 | 1 |
Week3 | 2 | 1.5 |
Week4 | 2 | 1.6 |
Week1 | 3 | 0.8 |
Week2 | 3 | 0.9 |
Week3 | 3 | 1.2 |
Week4 | 3 | 1.4 |
This will get you started 🙂
data have;
input Visit $ Patient score1;
datalines;
Week1 1 0
Week2 1 0.8
Week3 1 1.1
Week4 1 2
Week1 2 1
Week2 2 1
Week3 2 1.5
Week4 2 1.6
Week1 3 0.8
Week2 3 0.9
Week3 3 1.2
Week4 3 1.4
;
proc sgplot data = have;
series x = Visit y = score1 / group = Patient;
run;
This will get you started 🙂
data have;
input Visit $ Patient score1;
datalines;
Week1 1 0
Week2 1 0.8
Week3 1 1.1
Week4 1 2
Week1 2 1
Week2 2 1
Week3 2 1.5
Week4 2 1.6
Week1 3 0.8
Week2 3 0.9
Week3 3 1.2
Week4 3 1.4
;
proc sgplot data = have;
series x = Visit y = score1 / group = Patient;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.