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

Is there a way to output at-risk numbers at specific time points to a file? With the following code, it outputs below the graph and I need to use something like PROC PRINT to view the data.  Also it does not give heading on what the timepoints are.  I need to share this with others and I am not satified with the way it is presented currently.

 

Here's a sample code-


data vagcan;
   label days  ='Days from Exposure to Death'
         group ='Treatment Group';
   input days @@;
   censored = (days < 0);
   days = abs(days);
   if _n_ > 19 then group = 'pretrt1';
   else group = 'pretrt2';
   datalines;
143 164 188 188 190 192 206 209 213 216
220 227 230 234 246 265 304  -216  -244
142 156 163 198 205 232 232 233 233 233 233 239
240 261 280 280 296 296 323 -204 -344
;

PROC LIFETEST data=vagcan plots=survival(atrisk(outside(0.25))=150 160 180 300); 
   time days*censored(1);
strata Group; 
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
/*
As ballardw said, using ODS table to save these data.
*/
data vagcan;
   label days  ='Days from Exposure to Death'
         group ='Treatment Group';
   input days @@;
   censored = (days < 0);
   days = abs(days);
   if _n_ > 19 then group = 'pretrt1';
   else group = 'pretrt2';
   datalines;
143 164 188 188 190 192 206 209 213 216
220 227 230 234 246 265 304  -216  -244
142 156 163 198 205 232 232 233 233 233 233 239
240 261 280 280 296 296 323 -204 -344
;
ods select none;
ods output SurvivalPlot=SurvivalPlot ;
PROC LIFETEST data=vagcan plots=survival(atrisk(outside(0.25))=150 160 180 300) ; 
   time days*censored(1);
strata Group; 
run;
ods select all;

Ksharp_0-1713420268019.png

 

View solution in original post

6 REPLIES 6
Reeza
Super User
Have you tried the timelist option on the PROC LIFETEST?

I'm not quite sure exactly what you're looking for as well, can you more clearly illustrate what you're looking for in terms of graphics?
PamG
Quartz | Level 8

Timelist does not give at-risk numbers.

PamG
Quartz | Level 8

Timelist and ATRISK option gives identical results.  I am running this on my real data and the numbers are off.  Also on my real data, timelist gives a value of zero at the last time of followup while the ATRISK gives a number.  

ballardw
Super User

If you want something that appears in the results generally you can get that into a data set using ODS OUTPUT.

 

You use ODS TRACE to get a list of objects created by a procedure. Then use ODS OUTPUT statement(s) to place the output into a data set.

An example you can run:

ods trace on;

proc freq data=sashelp.class ;
   tables sex * age / chisq ;
run;

ods trace off;

The Log will show after the code in addition to typical log output:

Output Added:
-------------
Name:       CrossTabFreqs
Label:      Cross-Tabular Freq Table
Template:   Base.Freq.CrossTabFreqs
Path:       Freq.Table1.CrossTabFreqs
-------------

Output Added:
-------------
Name:       ChiSq
Label:      Chi-Square Tests
Template:   Base.Freq.ChiSq
Path:       Freq.Table1.ChiSq
-------------

The important part for getting the objects into data sets is the NAME: and what follows.

To get the basic frequency information is the Crosstabfreqs and the Chi-Square tests then name is Chisq.

So this code will create data sets Mycrosstabset and Mychisquareset with the results.

ods output crosstabfreqs= mycrosstabset
           chisq = mychisquareset
;
proc freq data=sashelp.class ;
   tables sex * age / chisq ;
run;

If you are generating plots the objects will include the plots and you can capture data from them.

 

Caveat: some of these ODS OUTPUT generated data sets have quite a bit more than appears in the results window and may take some work to get pieces you want for other purposes.

 

 

 

Ksharp
Super User
/*
As ballardw said, using ODS table to save these data.
*/
data vagcan;
   label days  ='Days from Exposure to Death'
         group ='Treatment Group';
   input days @@;
   censored = (days < 0);
   days = abs(days);
   if _n_ > 19 then group = 'pretrt1';
   else group = 'pretrt2';
   datalines;
143 164 188 188 190 192 206 209 213 216
220 227 230 234 246 265 304  -216  -244
142 156 163 198 205 232 232 233 233 233 233 239
240 261 280 280 296 296 323 -204 -344
;
ods select none;
ods output SurvivalPlot=SurvivalPlot ;
PROC LIFETEST data=vagcan plots=survival(atrisk(outside(0.25))=150 160 180 300) ; 
   time days*censored(1);
strata Group; 
run;
ods select all;

Ksharp_0-1713420268019.png

 

PamG
Quartz | Level 8

@Ksharp Thank you so much.  This is exactly what I was looking for!!!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 6 replies
  • 414 views
  • 1 like
  • 4 in conversation