DATA Step, Macro, Functions and more

Macro to create patient profiles

Reply
Contributor
Posts: 28

Macro to create patient profiles

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.

PROC Star
Posts: 7,481

Re: Macro to create patient profiles

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

Super User
Posts: 5,513

Re: Macro to create patient profiles

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.

Regular Contributor
Posts: 195

Re: Macro to create patient profiles

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

Ask a Question
Discussion stats
  • 3 replies
  • 202 views
  • 3 likes
  • 4 in conversation