BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Leo9
Quartz | Level 8

Hi All,

 

I need to display number of subjects at each visits at the bottom of the plot for a series plot. There are three different cohorts so I need to display three lines  of N (number of subjects) one for each cohort. I know the drawtext option but it requires lots of processing and playing around to get proper display. Is there any other option to do this ? 

1 ACCEPTED SOLUTION

Accepted Solutions
9 REPLIES 9
JeffMeyers
Barite | Level 11

That is what the AXISTABLE plot was made to do.  It has a CLASS option I believe to split into multiple rows and can also be colored differently if need be.  You can either use a lattice layout to make a space below your chart, or you can use an INNERMARGIN block within your current layout to include it above your X-axis.

Rick_SAS
SAS Super FREQ

The Graphically Speaking blog has many posts that feature the XAXISTABLE statement. Here's one to get started:

https://blogs.sas.com/content/graphicallyspeaking/2016/07/17/graph-table-with-class/

and another that shows a variation

https://blogs.sas.com/content/graphicallyspeaking/2018/02/19/survival-plot-twist-using-sgplot-proced...

 

Leo9
Quartz | Level 8

Thank you! This works nicely. However, I want to display N for certain visits only which are displayed on x-axis. Right now I am displaying visits on x-axis at 4 week interval using tickvalue sequence. Is there any option like that with axistable to display N ? 

Leo9
Quartz | Level 8

Hi All,

I am creating a series plot where I am displaying visits in 4 week interval using tickvaluesequence option in proc template. I need to display subject of subjects at each visit for which I am using axistable plot to display. Problem is that axistable is displaying N (number of subjects) for every week instead of every 4 weeks. Is there any option to display, like tickvaluesequence within axistable to display N for selected visits ? Thanks in advance. 

 

Rick_SAS
SAS Super FREQ

The XAXISTABLE statement in PROC SGPLOT (and the AXISTABLE statement in the GTL) displays the data in the variables that you specify.  For example, in SGPLOT the syntax is

xaxistable NumVisit x=Time class=Cohort;

 

So you should run a DATA step to aggregate the visits and store the 4-week times and totals in new variables NumVisit4 and Time4 for each cohort. Add those variable to the data set that you are plotting and specify the NumVisit4 and Time4 variables in the XAXISTABLE stmt.

JeffMeyers
Barite | Level 11

You could either do it in the data step (make a new variable that only has the values you want) or if it is as simple as taking every fourth week and your weeks are numbered sequentially you could use an EVAL function in the template:

axistable x=eval(ifn(mod(weeks,4)=0,weeks,.)) values=n_patients;

 

I don't know what your variables are but the above is an example of using the mod function to take the fourth week.  Changing the =0 to =1, =2, or =3 will grab a different week in the four week cycle.

Rick_SAS
SAS Super FREQ

That's a neat trick, but I think the OP wants to show the sum of the numbers for weeks 1-4 at the location for week 4.

Show the sum of the numbers for weeks 5-8 at the location for week 8, etc.

If so, using n_patients won't work. You have to sum the n_patients values.

JeffMeyers
Barite | Level 11

I'm not seeing anything in their post saying they want to aggregate numbers at certain time points, just that they want to pick which times they are displaying the counts.  I'm reading this like someone trying to print patients-at-risk on a survival curve at certain time-points.

Rick_SAS
SAS Super FREQ

Upon re-reading, I think you are probably right and I made an incorrect assumption. Sorry for the confusion. Thanks for clarifying.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 9 replies
  • 1406 views
  • 7 likes
  • 3 in conversation