1
votes

I wrote SAS code and I need to pass value depending upon the parameter value .. SAS Code run and get the required output

%MACRO FTIC(Student_Entry=, Admission_Year=,YEAR_TRACK=, TERM=, College );
...
...
...
%MEND FTIC;

%FTIC(Student_Entry= A, Admission_Year=2012 ,YEAR_TRACK=1, TERM=Summer/FALL )

Here are the values for each parameter: Student_Entry= A, B,C, D

Admission_year = 2012, 2013, 2014, 2015, 2016

Year_Track = 1, 2,3,4,5

Term= Summer/Fall, Spring

I am writing below lines more than 4*4*5*2 times lines. to achieve my result.

%FTIC(Student_Entry= A, Admission_Year=2012 ,YEAR_TRACK=1, TERM=Summer/FALL )

Can you please tell me how-how to write this more efficiently.

1

1 Answers

0
votes

OK. It looks like you want some way to automatically loop through these parameters and call the %FTIC macro for each combination of parameters.

  1. Create lists for the possible values of each parameter.

    %let stud_list = A B C D;
    %let Ad_list = 2012 2013 2014 2015 2016;
    %let YrT_list = 1 2 3 4 5;
    %let term_list = Summer/Fall Spring;

  2. Count the items in each list.

    %let stud_cnt = %sysfunc(countw(&stud_list),%str( ));
    %let Ad_cnt = %sysfunc(countw(&Ad_list),%str( ));
    %let YrT_cnt = %sysfunc(countw(&YrT_list),%str( ));
    %let term_cnt = %sysfunc(countw(&term_list),%str( ));

  3. Use a %do loop in a dummy macro to repeatedly call the %FTIC Macro.

    %macro dummy;
    %do i = 1 %to &stud_cnt; %do ii = 1 %to &ad_cnt; %do iii = 1 %to &yrt_cnt; %do iiii = 1 %to &term_cnt; %FTIC(student_entry = %scan(&stud_list,&i,%str( )), Admission_year = %scan(&Ad_list,&ii,%str( )), Year_track = %scan(&YrT_list,&iii,%str( )), Term = %scan(&term_list,&iiii,%str( )) ); %end; %end; %end; %end; %mend dummy; %dummy;