BookmarkSubscribeRSS Feed
mano
Calcite | Level 5

I Have created a macro for creating patient profiles.

%macro patprof ( subjid= );

..

..

..

..

%mend;

I have 550 patients in my study and I am calling my macro for every individual patient.

for example :-

%patprof(subjid= 101);

%Patprof(subjid=102);

%patprof(subjid=109);

is there any way that which improves my macro code so that I don't need to call my macro all 550 times for each patient.

My subjid are not consecutive numbers.

any help is appreciated.

3 REPLIES 3
art297
Opal | Level 21

You would have to post your macro in order for anyone to help

Astounding
PROC Star

Art is right ... without seeing your code we can give just the most general of answers.  With that in mind, there are two approaches that might be possible.

(1) You may be able to change your code so that it processes all patients using a BY SUBJID statement.  If appropriate, subset your data so it contains just the SUBJID values of interest (including the possibility of just a single SUBJID), and feed the subset to your code.

(2) You may be able to keep your code as is, but tell us a data set that contains all relevant values for SUBJID.  Then macro language could generate the 550 calls to your macro, instead of you having to type them.

Good luck.

UrvishShah
Fluorite | Level 6

Hi,

Based on your information provided, if youe SUBJID is not a consecutive numbers, then try the following code..It might works...

%macro test;

         

           proc sql noprint;

                 select distinct compress(subjid) into :_subjid separated by ' '

                 from have (keep = subjid);

           quit;

           %let i = 1;

           %let _subjid_ =  %scan(&_subjid.,&i.);

           %do %while(&_subjid_ NE);

                   %patprof(subjid= &_subjid_.);

                   %let i = %eval(&i + 1);

                   %let _subjid_ = %scan(&_subjid.,&i.);

           %end;

%mend test;

%test;

Hope it works...

Thanks,

Urvish

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
  • 872 views
  • 3 likes
  • 4 in conversation