BookmarkSubscribeRSS Feed
fengyuwuzu
Pyrite | Level 9

I want to plot the cumulative percentage of event over time, and have multiple arms, so I want to plot the curves in the single graph.

Time is continuous. event is 0 or 1.

 

Can anyone recommend an example how to do this?

 

 

5 REPLIES 5
Community_Guide
SAS Moderator

Hello @fengyuwuzu,


Your question requires more details before experts can help. Can you revise your question to include more information? 

 

Review this checklist:

  • Specify a meaningful subject line for your topic.  Avoid generic subjects like "need help," "SAS query," or "urgent."
  • When appropriate, provide sample data in text or DATA step format.  See this article for one method you can use.
  • If you're encountering an error in SAS, include the SAS log or a screenshot of the error condition. Use the Photos button to include the image in your message.
    use_buttons.png
  • It also helps to include an example (table or picture) of the result that you're trying to achieve.

To edit your original message, select the "blue gear" icon at the top of the message and select Edit Message.  From there you can adjust the title and add more details to the body of the message.  Or, simply reply to this message with any additional information you can supply.

 

edit_post.png

SAS experts are eager to help -- help them by providing as much detail as you can.

 

This prewritten response was triggered for you by fellow SAS Support Communities member @ballardw

.
ballardw
Super User

Example data

Which percentages you want calculated and plotted

 

The basic plot would be created once the data is summarized assuming you have variable to indicate which "arm" (what ever that may mean) the represents with:

 

proc sgplot data=want;

   series x=time y=percentagevalue/group=arm;

run;

 

Without seeing the data exactly how to calculate your percentages is problematical though Proc Freq is the first thing that comes to mind to do cumulative percentages of counts.

 

 

fengyuwuzu
Pyrite | Level 9
data have1;
 input ID $ arm $ event days ;
 datalines;
 001 A 1 10.5
 002 B 1 49.7
 003 A 1 14.5
 004 B 1 28.5
 005 A 1 37.9
 006 B 1 41.7
 007 A 1 18.3
 008 A 1 26.5
 009 A 1 39.3
 010 B 1 51.9
 011 B 1 31.7
 012 A 1 17.4
 013 B 1 25.3
 014 A 1 47.4
 015 A 1 15.7
 016 B 1 34.3
 017 B 1 47.5
 018 A 1 56.1
 019 B 1 27.8
 020 A 1 17.4
 021 B 1 43.3
 022 A 1 52.7
 023 A 1 64.8
 024 B 1 43.3
 025 A 1 52.7
 026 A 1 64.8
 027 B 1 43.3
 028 B 1 52.7
 029 B 1 64.8
 030 A 1 44.9
;
 run;


 data have2;
 input ID $ arm $ event days ;
 datalines;
 001 A 1 10.5
 002 B 1 49.7
 003 A 0 14.5
 004 B 0 28.5
 005 A 1 37.9
 006 B 1 41.7
 007 A 0 18.3
 008 A 1 26.5
 009 A 1 39.3
 010 B 0 51.9
 011 B 1 31.7
 012 A 1 17.4
 013 B 0 25.3
 014 A 0 47.4
 015 A 1 15.7
 016 B 1 34.3
 017 B 1 47.5
 018 A 1 56.1
 019 B 0 27.8
 020 A 0 17.4
 021 B 1 43.3
 022 A 0 52.7
 023 A 1 64.8
 024 B 1 43.3
 025 A 1 52.7
 026 A 0 64.8
 027 B 0 43.3
 028 B 1 52.7
 029 B 0 64.8
 030 A 0 44.9
;
 run;

In data have1, every one has event (event=1);

in data have2, only some have event (event=1)

 

want to get a plot of cumulative percentage of event in both situation 

ballardw
Super User

Does this do something like what you want for Have1?

proc sort data=have1;
   by arm days;
run;
proc freq data=have1;
   by arm;
   tables days/out=h1freq outcum;
run;

proc sgplot data=h1freq;
   series x=days y=cum_pct/group=arm;
   label cum_pct='Cumulative  Percentage';
run;

If that is close then the main difference for doing have2 would be to include a WHERE event=1; in the Proc freq.

 

fengyuwuzu
Pyrite | Level 9

Thank you very much 

 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1927 views
  • 0 likes
  • 3 in conversation