Home How to pass variable sequence (list) to SAS Macro
Reply: 0

How to pass variable sequence (list) to SAS Macro

user1078 Published in July 23, 2018, 1:41 pm

I have variables named _200701, _200702,... till _201612, each containing specific numeric data for that month. From these, I want to substract specific amount (variable cap_inc), if a condition is met:

%MACRO DeleteExc(var);
DATA Working.Test;
SET Working.Test;
    IF &var. GE cap_inc THEN &var. = SUM(&var., - cap_inc);
    ELSE &var. = &var.;

Code is working if I put only one month as a parameter (eg _200909)... But I want to put there sequence from these variables. I have tried combinations like "OF _200701 -- _201612" or "OF _20:", but nothing has worked.

I have also another macro, using parmbuff parameter, working in the "for each loop" way, where I can put more variables separated by comma, for instance

%DeleteExc(_200701, _200702, _200703)

But I still can't pass all variables in some convenient, easy to follow way. (I don't want to type all parameters as there is 120 of them).

Is there any way how to do this? Thank you!

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.544232 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO