BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
fengyuwuzu
Pyrite | Level 9
%macro rep(in=,param=,critn=,crit=);
proc report data=&in. nowd missing headskip headline split='^' ls=&ls;
     column ('--' avisitn avisit ("Treatment A^--^(N=%eval(&N1))^--^Number of Subjects (%)^--" (n1 n2 n3 n4 n5 n6 n7 n8)));
/*	 define param / order noprint;*/
/*	 define critn / order noprint;*/
/*	 define crit / order noprint;*/
	 define avisitn / order noprint;
	 define avisit  / "Visit " width=20 spacing=0 left flow display id;
	  define n1/"n" width=4 center spacing=1;
	  %if &critn.=1 %then %do;
	  define n2/"High *a" width=14 center spacing=1;
	  %end;
	  %if &critn.=2 %then %do;
	  define n2/"Low *a" width=14 center spacing=1;
	  %end;
	  define n3/"Grade 0" width=14 center spacing=1;
	  define n4/"Grade 1" width=14 center spacing=1;
	  define n5/"Grade 2" width=15 center spacing=1;
	  define n6/"Grade 3" width=15 center spacing=1;
	  define n7/"Grade 4" width=15 center spacing=1;
	  define n8/"Missing *c" width=15 center spacing=1;

/*	 break after crit/ page;*/
	 compute before _page_;
	  line @1 "&param.";
	  line @1 'CTCAE Criterion: ' "&crit.";
	 endcomp;

     compute after _page_ ;
	   line &ls*'-';
	   line @1 'Abbreviations: N = number of subjects in population;';
	   line @1 '               n = number of subjects with data collected (includes missing values) for a specific lab parameter at each timepoint.';
	   line @1 "The denominator for 'Worst' is the total number of patients who had at least one post-baseline value data point,";
	   line @1 "with value either missing or non missing.";
	   line @1 '*a -- <High/Low> category counts the number of subjects for whom the values of the given lab test are abnormally <High/Low>';
	   line @1 '      and the CTCAE criterion in the table header is defining values that are abnormally <Low/High>;';
	   line @1 "*c -- the 'missing' category displays the number of subjects who provided only missing data for the given visit.";
	   line @1 '';
/*	   line @1 "Data cut-off date: &cutoffdc;";*/
	   line @1 "Program Location:  &curpath\&pgmname..sas";
	   line @1 "Output Location :  %upcase(&outdir)\&outfile..rtf";
	   line @1 "Data Location   :  %upcase(&sdtm.)";
	   line @1 "                :  %upcase(&adam.)"; 
     endcomp;
run;
%mend;
%macro proc;
%do i=1 %to 67;
  %do j=1 %to 2;
   data temp1;
      set final;
	  where ord=&i and critn=&j;
	  call symput('param',param);
	  call symput('crit',crit);
   run;
   proc sql noprint;
  select count(*) into: nobs from temp1;
quit;
 
%if &nobs > 0 %then %do;
   %rep(in=temp1,param=&param,critn=&j,crit=&crit);
  %end;
%end;
%end;

%mend;

%proc;

I got the error:

NOTE: There were 26 observations read from the data set WORK.FINAL.
WHERE (ord=5) and (critn=1);
NOTE: The data set WORK.TEMP1 has 26 observations and 25 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds


NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds


ERROR:: All positional parameters must precede keyword parameters
NOTE: Line generated by the invoked macro "PROC".
500 %rep(in=temp1,param=&param,critn=&j,crit=&crit);
_____
180

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

NOTE: There were 0 observations read from the data set WORK.FINAL.
WHERE (ord=5) and (critn=2);
NOTE: The data set WORK.TEMP1 has 0 observations and 25 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

 

In the beginning the error appeared when (ord=17 and critn=1) ans also for (ord=38 and critin=2), but somehow now this appears for ord=5 and critn=1. I did not change anything. 

anyone knows about this error?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Since we can't see the data I have a suspicion that the value of &param as passed in this line:

%rep(in=temp1,param=&param,critn=&j,crit=&crit);

may contain a comma.

 

Suppose &param = value1, value2   the macro compiler may see something that looks like

%rep(in=temp1,param= value1, value2,critn=&j,crit=&crit);

 

Critn gets pointed as as the place for the error because it cannot point to "value2" in the error message.

 

Example that demonstrates the exact same problem:

%macro dummy(in=,param=,critn=,crit=);
%put &in &param &critn &crit;
%mend;

%let param= value1, value2;
%dummy (in=1, param=&param,critn=3, crit=4);

The fix will be to ensure that the &param passed to %rep does not have any comma OR macro quote it to ignore the comma.

 Examine the values of the variable Parm in the set Final.

Note that having PARAM in so many places is making it hard to distinguish between usages: Data step variable and at least 2 Macro variables.

View solution in original post

4 REPLIES 4
ballardw
Super User

Since we can't see the data I have a suspicion that the value of &param as passed in this line:

%rep(in=temp1,param=&param,critn=&j,crit=&crit);

may contain a comma.

 

Suppose &param = value1, value2   the macro compiler may see something that looks like

%rep(in=temp1,param= value1, value2,critn=&j,crit=&crit);

 

Critn gets pointed as as the place for the error because it cannot point to "value2" in the error message.

 

Example that demonstrates the exact same problem:

%macro dummy(in=,param=,critn=,crit=);
%put &in &param &critn &crit;
%mend;

%let param= value1, value2;
%dummy (in=1, param=&param,critn=3, crit=4);

The fix will be to ensure that the &param passed to %rep does not have any comma OR macro quote it to ignore the comma.

 Examine the values of the variable Parm in the set Final.

Note that having PARAM in so many places is making it hard to distinguish between usages: Data step variable and at least 2 Macro variables.

fengyuwuzu
Pyrite | Level 9

yes. that params is

BLOOD Neutrophils, Segmented (10^9/L)

 

there is a ,

ballardw
Super User

@fengyuwuzu wrote:

yes. that params is

BLOOD Neutrophils, Segmented (10^9/L)

 

there is a ,


You could either use a function in the data step to remove/replace the comma in the varialbe or change the macro call to look like:

%dummy (in=1, param=%quote(&param),critn=3, crit=4);

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
  • 4 replies
  • 23893 views
  • 2 likes
  • 2 in conversation