Problem 1:
"i have a script that works fine in normal SQL statement without macro."
Answer:
Learn Base SAS, you will find coding far simpler and easier rather than trying to force it through a third party software addon. For example, statement 1 is simply:
proc sort data=hpsncp.scada_mrcc_mv out=mrcc_asset nodupkey;
by substationcode substationname substationtype voltagetype;
where cats(substr(datetime_,7,4),substr(datetime_,4,2)="&period.";
run;
Problem 2: "The reason why i put in macro now is to handle period checking whereby different period will have different column from different source table."
Answer:
Re-assess your data modelling. If you find you are having to resort to macro programming to handle different data, then your underlying data is badly modelled. I can't tell exactly without seeing data, but if your calling the same macro with different groups, put those groups into your data, and then just use a by <groupvariable> statement, you will find it is a lot faster, simpler coding, and more efficient.
... View more