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

Hi all,

Hope the holiday season is going well for everyone. I am having issues with running the %newsurv macro for generating cumulative incidence curves. I have reviewed the %newsurv macro on the https://communities.sas.com/t5/SAS-Communities-Library/Kaplan-Meier-Survival-Plotting-Macro-NEWSURV/... website but when I am trying to apply it for my own data set, I am getting errors.

My data set name is Two, the duration variable is dur_Study_yrs and outcome of interest is PDAC (Yes=1, No=0), grouping variable of interest is Group (NON-Smoker, Past-Smoker, Smoker). I would like to keep Xaxis and Yaxis consistent for all the graphs I generate.

 


WARNING: Apparent invocation of macro NEWSURV not resolved.

 


ERROR 180-322: Statement is not valid or it is used out of proper order.

%newsurv (DATA=two, TIME=dur_study_yrs, CENS=PDAC, CEN_VL=0, SUMMARY=0, CLASS=GROUP, CLASSREF=NON-SMOKER, XINCREMENT=1, XMAX=10, YLABEL= cumulative incidence, RISKLIST 0 to 100 by 10, RISKLOCATION=BOTTOM, METHOD=CIF, EV_VL=1);

 

I would appreciate any help with this. 

 

I am attaching the pictures with the SAS macro and the error message that I am getting. IMG_7784 (002).jpgIMG_7785 (002).jpg 

1 ACCEPTED SOLUTION

Accepted Solutions
sms1891
Quartz | Level 8

Thank you for all the help. I found the macro at the bottom of the page where the macro examples are given.

 

 

https://communities.sas.com/t5/SAS-Communities-Library/Kaplan-Meier-Survival-Plotting-Macro-NEWSURV/...

 

 

View solution in original post

13 REPLIES 13
sms1891
Quartz | Level 8

My SAS is 9.04.01M5P091317. I have SAS 9.04, Operating system LIN X64. I uses SAS enterprise guide 7.1.

ballardw
Super User

Set OPTIONS MPRINT.

Run the macro.

Copy the text from log including the generated MPRINT output plus any errors. Paste the Text into a code box opened on the forum with the {I} to preserve formatting.

 

With the copied text we can highlight bits or copy/edit/paste changes to make suggestions or corrections. We can't do that with pictures.

And I at least can't get those images large enough to actually read any of the text.

sms1891
Quartz | Level 8

Hi ballard,

Thanks for the email. I work on the remote desktop server and It does not let me copy the log and post it on the blog. How should I go about this. 

 

I ran the syntax 

%newsurv (DATA=two, TIME=dur_study_yrs, CENS=PDAC, CEN_VL=0, SUMMARY=0, CLASS=GROUP, CLASSREF=NON-SMOKER, XINCREMENT=1, XMAX=10, YLABEL= cumulative incidence, RISKLIST 0 to 100 by 10, RISKLOCATION=BOTTOM, METHOD=CIF, EV_VL=1);

 

This is the error I am getting 

WARNING: Apparent invocation of macro NEWSURV not resolved.

 

ERROR 180-322: Statement is not valid or it is used out of proper order.

Shmuel
Garnet | Level 18

If possible use proc printto to save the log as text file in a directory you can read from

proc printto file="<path and file name>"; run;

... your code

proc printto; run;
Kurt_Bremser
Super User

@sms1891 wrote:

Hi ballard,

Thanks for the email. I work on the remote desktop server and It does not let me copy the log and post it on the blog. How should I go about this. 

 

I ran the syntax 

%newsurv (DATA=two, TIME=dur_study_yrs, CENS=PDAC, CEN_VL=0, SUMMARY=0, CLASS=GROUP, CLASSREF=NON-SMOKER, XINCREMENT=1, XMAX=10, YLABEL= cumulative incidence, RISKLIST 0 to 100 by 10, RISKLOCATION=BOTTOM, METHOD=CIF, EV_VL=1);

 

This is the error I am getting 

WARNING: Apparent invocation of macro NEWSURV not resolved.

 

ERROR 180-322: Statement is not valid or it is used out of proper order.


You did not run the macro definition first.

sms1891
Quartz | Level 8

Thanks for the response Kurt. How do I run the macro definition? Can you please clarify it for me?

 

 

Kurt_Bremser
Super User

@sms1891 wrote:

Thanks for the response Kurt. How do I run the macro definition? Can you please clarify it for me?

 

 


The macro definition starts with a %macro statement and ends with %mend. Run the whole code including both those statements, and then inspect the log to see if the macro compiled correctly. Then you can use it as documented.

ballardw
Super User

@sms1891 wrote:

Hi ballard,

Thanks for the email. I work on the remote desktop server and It does not let me copy the log and post it on the blog. How should I go about this. 

 

I ran the syntax 

%newsurv (DATA=two, TIME=dur_study_yrs, CENS=PDAC, CEN_VL=0, SUMMARY=0, CLASS=GROUP, CLASSREF=NON-SMOKER, XINCREMENT=1, XMAX=10, YLABEL= cumulative incidence, RISKLIST 0 to 100 by 10, RISKLOCATION=BOTTOM, METHOD=CIF, EV_VL=1);

 

This is the error I am getting 

WARNING: Apparent invocation of macro NEWSURV not resolved.

 

ERROR 180-322: Statement is not valid or it is used out of proper order.


Did you compile the macro?, i.e. run the code that starts with %macro newsurv (    ) through %mend;

If you don't compile the macro it is not available in the current SAS Session.

Example;

480  %dummy(a parameter);
     -
     180
WARNING: Apparent invocation of macro DUMMY not resolved.

ERROR 180-322: Statement is not valid or it is used out of proper order.

But if I submit the macro code first.

481  %macro dummy(parm);
482     %put &parm.;
483  %mend;
NOTE: The macro DUMMY completed compilation without errors.
      7 instructions 124 bytes.
484
485  %dummy(a parameter);
a parameter

Here it is easy to see that macro code was submitted and completed without errors. If you submitted the macro code but get an error the macro will not be available.

 

Or if you misspell the macro when using it, then a version is not available. Once the macro is compiled in the current session it should be available as long as the session runs. But you will need to resubmit the code the next time you want to use the macro.

 

If you need this macro frequently you may need to talk to your SAS admin about setting up an AUTOCALL library for macro code to be available for compilation when needed.

 

You can use proc printto to direct the log the a text file and then copy the file and attach that. If you can't copy text or files then make sure the resolution of the images posted is large enough to read. But the log with the MPRINT option can get quite lengthy and a single image could be quite obnoxious.

 

 

sms1891
Quartz | Level 8

Thanks ballard. I think I understood what you and Kurt were saying. I did not compile the macro, but can you be more specific with the compilation of macro for my data set? I am not sure what goes in parameter part of the macro code. Can you help me with that? 

 

I am offsite, if I get any further errors after running the macro, I will keep you posted for any help. 

 

 

%macro newsurv (parm)
%put &parm.;

%mend;



%newsurv (DATA=two, TIME=dur_study_yrs, CENS=PDAC, CEN_VL=0, SUMMARY=0, CLASS=GROUP, CLASSREF=NON-SMOKER, XINCREMENT=1, XMAX=10, YLABEL= cumulative incidence, RISKLIST 0 to 100 by 10, RISKLOCATION=BOTTOM, METHOD=CIF, EV_VL=1);

 

Kurt_Bremser
Super User

@sms1891 wrote:

I am not sure what goes in parameter part of the macro code.

 


Maxim 1: Read the Documentation, in this case the documentation of the macro. It will tell you how to run it.

Tom
Super User Tom
Super User

If the macro is properly designed then you do not change any of the original code for the macro definition.

Instead you pass in your values of the parameters when you call the macro.

ballardw
Super User

@sms1891 wrote:

Thanks ballard. I think I understood what you and Kurt were saying. I did not compile the macro, but can you be more specific with the compilation of macro for my data set? I am not sure what goes in parameter part of the macro code. Can you help me with that? 

 

I am offsite, if I get any further errors after running the macro, I will keep you posted for any help. 

 

 

%macro newsurv (parm)
%put &parm.;

%mend;



%newsurv (DATA=two, TIME=dur_study_yrs, CENS=PDAC, CEN_VL=0, SUMMARY=0, 
CLASS=GROUP, CLASSREF=NON-SMOKER, XINCREMENT=1, XMAX=10,
YLABEL= cumulative incidence, RISKLIST 0 to 100 by 10,
RISKLOCATION=BOTTOM, METHOD=CIF, EV_VL=1);

 


I really dislike lines of code that exceed the window width so I wrapped your macro call for readability.

I strongly suspect that you are missing an = after Risklist.

 

Also your "dummy" version of Newsurv is missing a semicolon at the end of the %macro statement and that macro won't compile properly.

sms1891
Quartz | Level 8

Thank you for all the help. I found the macro at the bottom of the page where the macro examples are given.

 

 

https://communities.sas.com/t5/SAS-Communities-Library/Kaplan-Meier-Survival-Plotting-Macro-NEWSURV/...

 

 

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