Advanced (Intro) to SAS Macro Programming (Part 3)

The First part and the Second part of this introduction talked about some basic things every beginner  needs to know when using SAS Macro Language.

In this part we will talk about :

  1. Dynamically storing a value into a macro variable
  2. Iterative statements in macro language (Next part)
  3. Conditional statements in macro language (Next part)


1-Dynamically storing a value into a macro variable

/* Calculating an average value and storing it in a macro variable*/

Proc Means Data = SASHELP.heart noprint;
Var height;
Output out = test mean= avg_height;
Run;





Proc SQL noprint;
Select avg_height into :var1
from test;

Quit;

%Put &var1;





An other way to store a value into a macro variable, is to use the SYMPUT function:

CALL SYMPUT(macro_varname,value);


Data _null_;
set test;
call SYMPUT ('var2',avg_height);
run;
%Put &var2;






Popular posts from this blog

Mathematical Symbols in LATEX

Analyzing Twitter data with R (part 3: Cleaning & organizing the Data)

Linkin Park: Analyzing the causes of death of Rock band members