%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);
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?
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);
You're stilling mixing up your macro variables. &pt and &u.
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
But, do they both exist? And are you using &pt when you should be using &u? And where is &u defined or assigned.
I have commented the code place it back, can anyone help
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.
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.