Programming the statistical procedures from SAS

Searching for Macro Tips

Reply
Occasional Contributor
Posts: 16

Searching for Macro Tips

Hi

While running SAS for my research, I have
some problem with ‘MACRO’ things. So, anyone who know how to solve my problem
please help me.

I want to find the ‘decay parameter’ which
results the maximum concurrent rate in logistics regression model. And before
that I need to make some dataset which differ according to its decay parameter

Here’s my original codes

%macro m2;

data ana2_macro; set ana2;

decay=0. 1;

       F2=d0_log_count*decay+d1_log_count;

       T2=d0_H_PV*decay+d1_H_PV;

       E2=d0_spd*decay+d1_spd;

       Sq_E2=d0_spd_sq*decay+d1_spd_sq;

run;

%mend m2;

And the problem is I want to make decay from 0.1 to 1 (0.1, 0.2, 0.3 …) automatically by using &n or something, but I don’t
know how to make it. So, can you give me some advice on this?

Thanks

Grand Advisor
Posts: 16,926

Re: Searching for Macro Tips

Why do you need a macro for that? Use a do loop and then process using a by variable.

data ana2_macro;

set ana2;

do decay=0.1 to 0.5;

       F2=d0_log_count*decay+d1_log_count;

       T2=d0_H_PV*decay+d1_H_PV;

       E2=d0_spd*decay+d1_spd;

       Sq_E2=d0_spd_sq*decay+d1_spd_sq;

output;

end;

run;

SAS Super FREQ
Posts: 3,319

Re: Searching for Macro Tips

For a related discussion of macro processing versus BY-group processing, see the article Simulation in SAS. (Bonus: It includes a comment from Reeza!)

Ask a Question
Discussion stats
  • 2 replies
  • 107 views
  • 0 likes
  • 3 in conversation