05-28-2012 10:50 AM
An Excel formula is different from a SAS Macro program. For example, if you build a formula in Excel for a new column (D) based on multiplying the value in column B by the value in column C, you might have a formula like:
and then you might copy that formula down the entire column D (see excel formula part of the screenshot) in order to populate the whole column with values.
But in SAS, if column B represented VALUE and column C represented DISCOUNT and column D represented DISCVAL (final discount value), then you would calculate DISCVAL this way (in a longer program shown in screenshot):
DISCVAL=VALUE * DISCOUNT;
So I'm not sure you really need a SAS Macro program. It might be overkill to use a SAS macro program to create a new variable, if that's all you wanted/needed to do. I wonder whether it might be better to read about basic SAS concepts, like DATA step processing and how to write a SAS program. SAS is not a WYSIWYG application (what you see is what you get), like Excel or Word. You can't manipulate SAS variables in the same way that you can manipulate values in a worksheet. A SAS macro program does not operate the same way than an Excel macro operates.
To effectively use SAS macro programs and macro variables, you really need to understand the basics of using SAS, because the first "rule" of macro is to have a working SAS program. Here's a good paper on the basics of DATA step programming:
and the documentation has some good sections:
And, for overview information about SAS Macro processing, this is a good paper: