BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Dennis_Lam
Calcite | Level 5

Hi, I have problem on passing parm to a macro wish someone can give me a hand. Following is the script that I have. I am trying to pass parm to the macro using a do loop but it was not successful. Can anyone give me some advice. thanks.

DATA rev_data;
FORMAT rep_month $7. ;
INPUT @1 rep_month $7.;
CARDS;
2012-01
2012-02
2012-03
;


data rev_data; set rev_data;
by rep_month;
   if first.rep_month then do;
     cnt = left(put(_n_,6.));
    call symput('mth'||cnt, rep_month);
    call symput('mthcount', cnt);
    end;
run;
%put _user_;
 
%macro a(m_mth, m_mthcount);


  %put month = &m_mth. count = &m_mthcount.;
%mend;
%a(&mth1, &mthcount);
data _d_;
  do i = 1 to &mthcount;
   runmth = '&mth'||i;
   %a(&mth||i,i);
  end;
   run;

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

For the last part of your code, I have modified it to macro, hopefully it is what you want:

%macro test;

data _d_;

  %do i = 1 %to &mthcount;

   runmth = "&&mth&i";

   output;

   %a(&&mth&i,&i);

  %end;

   run;

   %mend;

   %test

   proc print;run;

Kindly Regards,

Haikuo

View solution in original post

2 REPLIES 2
Haikuo
Onyx | Level 15

For the last part of your code, I have modified it to macro, hopefully it is what you want:

%macro test;

data _d_;

  %do i = 1 %to &mthcount;

   runmth = "&&mth&i";

   output;

   %a(&&mth&i,&i);

  %end;

   run;

   %mend;

   %test

   proc print;run;

Kindly Regards,

Haikuo

Dennis_Lam
Calcite | Level 5

Hi HaiKuo, thank you for your help.. Your solution work.. thanks a lot...

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
  • 2 replies
  • 660 views
  • 3 likes
  • 2 in conversation