BookmarkSubscribeRSS Feed
vraj1
Quartz | Level 8

I have a macro program which calls screened and screenfailure and it is optional. Below in the datastep i use these for calculating. If i change in the macro call instead of screened as screening and scrn fail instead of screenfailure can i make the datastep also change. I Know it is weird but can there any step where i can do.

 

		if upcase(DSTERM) in ("SCREENING" "SCREENED") then do;
		   %if &TotIncl ne %then %do;
		      &armvar="&TotName";
		   %end;
		    descr='Patients screened';
			sort1=1;
			sort2=1;
			n=count;
			n_pct=.;
			output;
		end;

		%* Screen failure*;
	    if upcase(DSTERM) in ("SCREENING FAILURE" "SCREEN FAILURE") then do;
		   %if &TotIncl ne %then %do;
		      &armvar="&TotName";
		   %end;
		   descr='Screening failures';
		   n=count;
		   n_pct=.;
           sort1=2;
		   sort2=1;
		   output;
		end;

macro call is

%macro inc(	
        Anl = sdtm.ds,
	AnlSel = %quote(DSTERM in ("SCREENED" "SCREEN FAILURE"))
etc...
);

any help

3 REPLIES 3
Satish_Parida
Lapis Lazuli | Level 10

Sas Documentation for call Execute, it is to call macro from a datastep execution.

 

http://documentation.sas.com/?docsetId=mcrolref&docsetTarget=n1q1527d51eivsn1ob5hnz0yd1hx.htm&docset...

 

 

data xxx;
.....

call execute('%inc(Anl = '||sdtm.ds/*Data step Variable*/||', AnlSel = %quote(DSTERM in ("SCREENED" "SCREEN FAILURE"))');


.....

run;

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Your post makes no sense at all.  You give a brief definition of a macro called inc which is not used anywhere in the code given.  You call macros which you have not given any description.

Second up, why do you even need all these macros and such like, your just overcomplicating things for the purpose of doing it.  If you want to do some logic for screened data and some other code for non-screen then this is an if/then scenario e.g:

...
  if upcase(dsterm) in ("SCREENING","SCREENED") then do;
    /* Code to do if true */
  end;
  else do;
    /* Code to do if false */
  end;
...

Also DSTERM is a standard variable from the DS domain, why are you needing to upper case it, and check if it is in a list, the values should already be consistent within you SDTM domain - possible even as part of a value list.

Reeza
Super User

You're mixing macro and data step logic and with out the rest of the code or any sort of sample data or a clear question it's going to be really hard to help you. 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 652 views
  • 1 like
  • 4 in conversation