Hi all ,
I've attached my code below. I am unable to resolve the MACRO error :All positional parameters must precede keyword parameters
Any help is appreciated
%macro prior_reg(dataset,cohort,whrcls,linenumber,title);
*where line numebr at index is either 1 ,2 or ge 3;
data &dataset.&linenumber. ;
set &cohort.;
where &whrcls.;
run ;
*the regimen immediately prior to the index regimen will be reported for patients with an line number at index of 1,2 or ge 3;
proc sql;
create table &dataset._reg&linenumber. as
select distinct a.PatientID,a.index_date,a.line_index,b.StartDate,b.LineName,b.LineNumber
from &dataset.&linenumber. as a
left join dfi_panc.Lineoftherapy as b
on a.PatientID =b.PatientID and (b.StartDate lt a.index_date)
order by a.PatientID, b.StartDate ;
quit ;/*244*/
*taking the regimen immediately before the index date ;
data &dataset._last_reg&linenumber.;
set &dataset._reg&linenumber.;
by PatientID StartDate;
if last.PatientID ;
run ;
proc freq data =&dataset._last_reg&linenumber.;
tables LineName /out= &dataset.prior_reg&linenumber.;
run ;
ods csv file ="/data1/projects/IPS/IPS_19/results/''&dataset.'.csv";
proc print data = &dataset.prior_reg&linenumber. ;
title &title.;
run ;
ods csv close ;
%mend prior_reg;
%prior_reg(_03a_folfiri,derived._00a_cohort_folfiri,1,line_index=1,'folfiri-1');
%prior_reg(_03a_folfiri,derived._00a_cohort_folfiri,2,line_index=2,'folfiri-2');
%prior_reg(_03a_folfiri,derived._00a_cohort_folfiri,3,line_index ge 3,'folfiri-3');
%prior_reg(_03a_folfiri,derived._00a_cohort_folfiri,4,PatientID ne ' ' ,'folfiri-4');
%prior_reg(_03b_folfox,derived._00b_cohort_folfox,1,line_index=1,'folfox-1');
%prior_reg(_03b_folfox,derived._00b_cohort_folfox,2,line_index=2,'folfox-2');
%prior_reg(_03b_folfox,derived._00b_cohort_folfox,3,line_index ge 3,'folfox-3');
%prior_reg(_03b_folfox,derived._00b_cohort_folfox,4,PatientID ne ' ','folfox-4');
You get this error because all your parameters are positionnal parameters and you are trying to address some of them as name parameters (i.e.: line_index=2).
Run your macro with MPRINT and SYMBOLGEN on and post the results from the log.
This is likely the issue as SAS would interpre that as trying to pass as a parameter. You can try masking it with macro masking functions.
line_index=1
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.
Ready to level-up your skills? Choose your own adventure.