BookmarkSubscribeRSS Feed
avama
Calcite | Level 5

Hi. I have about total of 500 patient and each patient has multiple volumes per time. So the dataset is the long format (multiple records per patient instead of one patient per row).

 

The x-axis should be the date_time

The y-axis should be 1) volume_1 line connected and 2) volume_2 connected

 

However, I would like to export each patient in one PDF file or multiple PDF. But I am really struggling with it. I tried proc plot etc, but no luck. Really appreciate the help! Thank you!

 

Here is the sample table: 

iddate_timevolume_1volume_2
14/19/14 9:51 PM  
14/19/14 9:56 PM41.756.20
14/20/14 12:53 PM50.825.00
14/21/14 8:38 PM51.774.70
14/22/14 5:51 PM  
24/23/14 1:34 PM55.186.00
27/3/14 12:50 AM14.312.40
27/3/14 3:34 PM12.680.80
27/3/14 9:00 PM10.990.90
27/4/14 3:30 PM8.161.20
5 REPLIES 5
Rick_SAS
SAS Super FREQ

So you want 500 plots, where each plot is for a patient and each plot shows volume_1 and volume_2?

If so, try

 

proc sgplot data=Have;
by id;
series x=date_time y=volume_1;
series x=date_time y=volume_2;
run;

Here is some sample data that we all can run, in case you have additional questions:

 

proc sgplot data=sashelp.stocks;
by stock;
series x=Date y=open;
series x=Date y=close;
run;
avama
Calcite | Level 5

Thank you so much! It works!! Couple more questions

- Is there any way that I can include the randomization_date and treatment group on the graph title or something? I don't need on the line graph but next the to ID name?

- Also right now, my y axis is showing volume_1. How do I relabel as "Volume" only? Since this is a line graph, is there any way I can get scatter dot? 

 

Thank you!

Rick_SAS
SAS Super FREQ

- Is there any way that I can include the randomization_date and treatment group on the graph title or something? I don't need on the line graph but next the to ID name?

 

Please post example data. 

 

- Also right now, my y axis is showing volume_1. How do I relabel as "Volume" only? Since this is a line graph, is there any way I can get scatter dot? 

 

Yes to both questions. 

- Add a YAXIS statement and use the LABEL= option, such as

YAXIS label="Volume";

- To get the scatter plot, use the SCATTER statement and put the name of your observed response on the Y= option:

scatter x=date_time y=NAME_OF_OBSERVED_VARIABLE;

avama
Calcite | Level 5

Thanks so much. I really appreciate it. 

 

So basically I want scatter line connect plot. X-axis = date_time and y-axis should be volume_1 and volume_2. Each graph should show id and group name. The y-axis should say: "Volume'

 

Something like this:

 

iddate_timevolume_1volume_2group
14/19/14 9:51 PM  placebo
14/19/14 9:56 PM41.756.20placebo
14/20/14 12:53 PM50.825.00placebo
14/21/14 8:38 PM51.774.70placebo
14/22/14 5:51 PM  placebo
24/23/14 1:34 PM55.186.00drug
27/3/14 12:50 AM14.312.40drug
27/3/14 3:34 PM12.680.80drug
27/3/14 9:00 PM10.990.90drug
27/4/14 3:30 PM8.161.20

drug

Rick_SAS
SAS Super FREQ

You should really make a minimal effort to read the documentation and try to modify the code yourself before you respond with more questions. We are here to help you learn, which happens best when you actively work through the questions you ask.

 

To answer your questions:

1. Sort your data:   BY Group ID date_time;

2. Plot the data:  BY Group ID;

3. Add the MARKERS option to the SERIES statements: SERIES x= ... y=...  / MARKERS;

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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