BookmarkSubscribeRSS Feed
desireatem
Pyrite | Level 9

%let pt=pt;

%macro pat(patt=);

%do &pt=1 %to &patt;  /*** I NEED THE BASELINE COVARIATE FOR AGE=0, So for each data below new_1, new_2, I want the first to set the covariates=Pattern_1, covariates=Pattern_2*/

data Pattern_&pt;

age=0;

output;

run;

%end;

%mend pat;

%MACRO DO_BRANCH(replicates=);

%do u=1 %to &replicates;

proc surveyselect data=new  method = urs sampsize = 141 OUTHITS

     reps=1 seed=1234100 out=new_&u;

run;

%pat(patt=2);

ods trace on /listing;

ods graphics on;

ods output ParameterEstimates=CPHH_&u;

proc phreg data=new_&u ;

model monset*obs(0)=age;

*baseline out=survs survival= survival;

baseline covariates=Pattern_&pt out=survs_&u survival= survival;  /* THe issue is that SAS doesnot seem to understand that I want covariates=pattern_1 when running the data set new_1 and covariates=pattern_2 for new_2*/

run;

ods trace off;

%end;

%MEND DO_BRANCH;

%DO_BRANCH(repli

cates=2);

6 REPLIES 6
Reeza
Super User

Try commenting the above code, every line, with what you expect and repost. 

Pay attention to where your macro variables are, a macro variable inside a macro is a local macro variable and does not exist outside the macro (for example &pt). You have two macro variables, &pt and &u, are each where you expect them to be?

desireatem
Pyrite | Level 9

Thanks .This is what I have:

%macro pat(patt=);

%do pt=1 %to &patt;

data Pattern_&pt;

age=0;

output;

run;

%end;

%mend pat;

%MACRO DO_BRANCH(replicates=);

%do u=1 %to &replicates;

proc surveyselect data=new  method = urs sampsize = 141 OUTHITS

     reps=1 seed=1234100 out=new_&u;

run;

%pat(patt=2);

ods trace on /listing;

ods graphics on;

ods output ParameterEstimates=CPHH_&u;

proc phreg data=new_&u ;

model monset*obs(0)=age;

*baseline out=survs survival= survival;

baseline covariates=Pattern_&pt out=survs_&u survival= survival;

run;

CODES>>>>>>>

%end;

%MEND DO_BRANCH;

This does not work

%DO_BRANCH(replicates=2);

Reeza
Super User

You're stilling mixing up your macro variables.  &pt and &u.

desireatem
Pyrite | Level 9

I do not know how I am mixing them up both are 2. Can you help show me how to correct it so that I do not mix them up

Reeza
Super User

But, do they both exist? And are you using &pt when you should be using &u? And where is &u defined or assigned.

desireatem
Pyrite | Level 9

I have commented the code place it back, can anyone help

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1700 views
  • 0 likes
  • 2 in conversation