I'm writing a SAS program that I need to run many different times, with the values of some of the variables changing each time. Is there some SAS programming tool that will make this easier?
Create SAS macro variables with the %LET statement. The syntax for the %LET statement is:
%LET macvname = value ;
where "macvname" is a variable name you specify and "value" is a numeric value you specify. This value will remain constant throughout the program. The %LET statement is usually placed at the beginning of the program for ease of access.
For example, suppose that you had a variable named N in your SAS program and the first time you ran the program you assigned it the value 24. However, you wish to rerun the SAS program with N=30, N=45, etc. Instead of changing the assignment statement (perhaps deep within your program) each time, you need only change the value given in the %LET statement at the beginning of the program. However, the macro variable name (here N) defined in the %LET statement must now be preceded by an ampersand (&) in subsequent statements. For example:
%LET Expected = 12 ;
Numer = Obtained - &Expected ;
Numersq = Numer**2 ;
CellChi = NumerSq / &Expected ;
RUN ;
Whenever SAS encounters the "&Expected" expression in this program, it will substitute the value of "Expected" that was defined in the %LET statement. In this example, SAS will substitute the user-supplied value of 12 every time it encounters the "&Expected" expresssion.
For more information, click on the Help button in the SAS menu bar and scroll to SAS Help and Documentation.
If you have further questions, send E-mail to stats@ssc.utexas.edu.