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

I have the follwing macro. It does not show any error but is not executed either. Please help me fix it. Thanks.

%macro surv(filenm, str=, fin=);

%let k=&str; l=&fin; %let name=&filename;

%let var1=a_cmb; %let var2=a_ip; %let var3=a_er;

%let var4=d_cmb; %let var5=d_ip; %let var6=d_er;

%do i=&k %to &l;

    var=&&var&i; *(' tried "&&var&i" also );

   title "PD_file-&name, event-&var";

   proc phreg data=event_pd_&name;

   model &var_time*&var_event(0)=  age cci  pd / ties=efron;

   array pd_a(*) pd_q1-pd_q8;

     t=ceil(&var_time/90); pd=pd_a;

   run;

   title;

%end;

%mend;

%surv(min, str=4, fin=5);

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

Hi,

I have not read through your code, but one thing pop out instantly: You did not define &filename in your macro (unless you did it somewhere else, and then 'filenm' was defined but never called), yet you call for it. My guess is that you typo parameter "filenm" with 'filename'. Not sure if this is the cause,  but it just does not seem right.

Haikuo

View solution in original post

5 REPLIES 5
Haikuo
Onyx | Level 15

Hi,

I have not read through your code, but one thing pop out instantly: You did not define &filename in your macro (unless you did it somewhere else, and then 'filenm' was defined but never called), yet you call for it. My guess is that you typo parameter "filenm" with 'filename'. Not sure if this is the cause,  but it just does not seem right.

Haikuo

brs2012
Calcite | Level 5

@Hai-Kuo; thanks, smart catch, but it is typo here. It was ok in the original one but problem is still there.

Haikuo
Onyx | Level 15

options mlogic mprint symbolgen;

Then post the log, or maybe you can then figure it out yourself.

Haikuo

update: from your code,

1. "var" was not defined as macro variable, so '&var' should not be resolved.  add '%let' to  'var=&&var&i;'

2. &var_time, &var_event was not defined. What you want maybe: &var._time, &var._event

Astounding
PROC Star

At a minimum, start with:

The word %LET is missing from I=&fin.

What is the purpose of:  var=&&var&i;

It generates a DATA step assignment statement, without the rest of the DATA step.

Also note that you have unmatched single quotes in the comment line that you added.  It's not clear if that's really part of the code you ran or not but get rid of unmatched quotes.

And of course, whatever the results, show us the earlier pieces of the code.  Some of these macro variables are coming out of nowhere.

Good luck.

brs2012
Calcite | Level 5

Lots of thanks to both of you!!! Yes, code ran.

@ Haikuo: Enabling Options, comments 1 & 2 were of great help.

@ Astounding: adding %let worked. &&var&i added to pick and assign values selectively.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 905 views
  • 6 likes
  • 3 in conversation