SlideShare une entreprise Scribd logo
1  sur  117
When Best to Use the %LET Statement, the SYMPUT Routine, or the INTO Clause to Create Macro Variables Arthur Li Department of Information Science City of Hope Comprehensive Cancer Center  Duarte, CA
INTRODUCTION DATA Step  PROC Steps SAS Macro  Facility BASE SAS Use to generate SAS codes more… PROC SQL
INTRODUCTION DATA Step  PROC Steps SAS Macro  Facility BASE SAS more… PROC SQL ,[object Object],[object Object],SAS Macro Variables SAS Macro  Programs Prerequisites: Focus of this talk
INTRODUCTION DATA Step  PROC Steps SAS Macro  Facility BASE SAS more… PROC SQL ,[object Object],[object Object],SAS Macro Variables SAS Macro  Programs Prerequisites: SAS Macro Variables SAS Macro Variables Automatic User- Defined Focus of this talk
THE %LET STATEMENT ,[object Object],%LET  MACRO-VARIABLE = VALUE; %let  var1 = 4 + 3; ,[object Object],MACRO-VARIABLE var1 VALUE 4 + 3 ,[object Object]
THE %LET STATEMENT ,[object Object],%LET  MACRO-VARIABLE = VALUE; %let  var2 =  leading blank; ,[object Object],MACRO-VARIABLE var2 VALUE leading blank ,[object Object]
THE %LET STATEMENT ,[object Object],%LET  MACRO-VARIABLE = VALUE; %let  var3 = " quotations "; ,[object Object],MACRO-VARIABLE var3 VALUE “  quotations ” ,[object Object]
THE %LET STATEMENT ,[object Object],%LET  MACRO-VARIABLE = VALUE; ,[object Object]
REFERENCING MACRO VARIABLES ,[object Object],%let  ht = 63;  ht  63 User-Defined Macro Variables: … … SYSTIME  10:34 SYSDAY  Monday SYSDATE  19JUN06 SAS Automatic Macro Variables: Global Symbol Table
REFERENCING MACRO VARIABLES ,[object Object],%let  ht = 63; data  ex1; set  height; tall = height > &ht; run ; ht  63 & MACRO-VARIABLE  63 ,[object Object],“ & MACRO-VARIABLE” User-Defined Macro Variables: … … SYSTIME  10:34 SYSDAY  Monday SYSDATE  19JUN06 SAS Automatic Macro Variables: Global Symbol Table
UNDERSTANDING SAS PROCESSING ,[object Object],Compilation phase Each statement is scanned for syntax errors Execution phase The DATA step reads and processes the input data the descriptor portion is created  If there is no syntax error Done in the compiler How are the SAS statements transferred to the compiler? A DATA step is processed in sequence in two phases
UNDERSTANDING SAS PROCESSING ,[object Object],data  ex1;  set  height; tall = height >  63 ; run ; INPUT STACK
[object Object],[object Object],[object Object],[object Object],UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK data  ex1;  set  height; tall = height >  63 ; run ;
data UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ex1;  set  height; tall = height >  63 ; run ;
ex1 data UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ;  set  height; tall = height >  63 ; run ;
; ex1 data UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK set  height; tall = height >  63 ; run ;
set ; ex1 data UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK height; tall = height >  63 ; run ;
height set ; data  ex1 UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ; tall = height >  63 ; run ;
; height set data  ex1; UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK tall = height >  63 ; run ;
tall ; height data  ex1;  set UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK = height >  63 ; run ;
= tall ; data  ex1;  set height UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK height >  63 ; run ;
height = tall data  ex1;  set height; UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK >  63 ; run ;
> height = data  ex1;  set height; tall UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK 63 ; run ;
63 > height data  ex1;  set height; tall = UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ; run ;
; 63 > data  ex1;  set height; tall = height UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK run ;
run ; 63 data  ex1;  set height; tall = height > UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ;
; run ; data  ex1;  set height; tall = height >  63 UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK
; run data  ex1;  set height; tall = height >  63 ; UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK
; data  ex1;  set height; tall = height >  63 ;  run UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK
data  ex1;  set height; tall = height >  63 ;  run ; ,[object Object],UNDERSTANDING SAS PROCESSING Compilation phase Each statement is scanned for syntax errors.  Execution phase The DATA step reads and processes the input data. If there is no syntax error WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK
UNDERSTANDING SAS PROCESSING Types of Token  Contains …  Examples  Literal  Characters enclosed in quotation marks “ John”  ‘John’  Numerals including decimals, E-notation, date, time, datetime constants, and hexadecimal constants 555 ‘ 01mar2010’d 30e4 Number Characters that begin with a letter or underscore and that continues with underscores, letters, or numbers.  A period can sometimes be part of a name _n_ means dollar9.2 Descending Name Characters other than a letter, number, or underscore that have a special meaning to the SAS system Special character /  +  %  &  . ;
[object Object],[object Object],MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK %let  ht =63;  data  ex1;  set  height; tall =height >&ht;  run ; MACRO PROCESSOR
[object Object],[object Object],[object Object],[object Object],MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK %let  ht =63;  data  ex1;  set  height; tall =height >&ht;  run ; MACRO PROCESSOR
% MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK let  ht =63;  data  ex1;  set  height; tall =height >&ht;  run ; MACRO PROCESSOR
let % ,[object Object],MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ht =63;  data  ex1;  set  height; tall =height >&ht;  run ; MACRO PROCESSOR
ht let % MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK =63;  data  ex1;  set  height; tall =height >&ht;  run ; MACRO PROCESSOR
= ht let % MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK 63;  data  ex1;  set  height; tall =height >&ht;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables
; 63 = ht MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK data  ex1;  set  height; tall =height >&ht;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables
data ; 63 = MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ex1;  set  height; tall =height >&ht;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht
ex1 data ; 63 ,[object Object],MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ;  set  height; tall =height >&ht;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht
; ex1 data MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK set  height; tall =height >&ht;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
set ; ex1 data MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK height; tall =height >&ht;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
height set ; data  ex1 MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ; tall =height >&ht;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
; height set data  ex1; MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK tall =height >&ht;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
tall ; height data  ex1;  set MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK =height >&ht;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
= tall ; data  ex1;  set height MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK height >&ht;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
height = tall data  ex1;  set Height; MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK >&ht;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
> height = data  ex1;  set height; tall MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK &ht;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
& > height data  ex1;  set height; tall = MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ht;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
ht & > data  ex1;  set height; tall = height ,[object Object],MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
ht & data  ex1;  set height; tall = Height > MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
ht data  ex1;  set height; tall = Height > MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
ht data  ex1;  set height; tall = Height > ,[object Object],MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
ht data  ex1;  set height; tall = Height > 63   MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
data  ex1;  set height; tall = Height > 63   MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
data  ex1;  set height; tall = Height > MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK 63 ;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
63 data  ex1;  set height; tall = Height > MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
; 63 data  ex1;  set height; tall = Height > MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
run ; 63 data  ex1;  set height; tall = Height > MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
; run ; data  ex1;  set height; tall = Height >  63 MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
; run data  ex1;  set height; tall = Height >  63 ; MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
; data  ex1;  set height; tall = Height >  63 ;  run MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
data  ex1;  set height; tall = Height >  63 ;  run; MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . . User-Defined Macro Variables   ht  63
PROCESSING MACRO VARIABLES AT EXECUTION TIME ,[object Object],[object Object],[object Object],[object Object],[object Object]
PROCESSING MACRO VARIABLES AT EXECUTION TIME ,[object Object],[object Object],[object Object],[object Object],[object Object],Ex1: 64 62 60 65 height 1 f Helen 4 0 f Mary 3 0 m Tom 2 1 m John 1 tall sex name
PROCESSING MACRO VARIABLES AT EXECUTION TIME Ex1: data   _null_ ; set  ex1 end=last; if  tall  then  count_tall + 1 ; if  last  then   do ; if  count_tall  then   do ; %let  titl = "Some students are taller than 63 inches"; end ; else   do ; %let  titl = "None of the students are taller than 63 inches"; end ; end ; run ; 64 62 60 65 height 1 f Helen 4 0 f Mary 3 0 m Tom 2 1 m John 1 tall sex name
PROCESSING MACRO VARIABLES AT EXECUTION TIME Ex1: proc   print   data =ex1; title  &titl; run ; None of the students are taller than 63 inches Obs  name  sex  height  tall 1  John  m  65  1 2  Tom  m  60  0 3  Mary  f  62  0 4  Helen  f  64  1 64 62 60 65 height 1 f Helen 4 0 f Mary 3 0 m Tom 2 1 m John 1 tall sex name
PROCESSING MACRO VARIABLES AT EXECUTION TIME WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK data   _null_ ;  set  ex1 end=last;  if  tall  then  count_tall + 1 ;  if  last  then   do ;  if  count_tall  then do ;  %let  titl ="Some students are taller than 63 inches";  end ;  else   do ;  %let  titl =  "None of the students are taller than 63 inches";  end ;  end ;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . User-Defined Macro Variables
titl let % data   _null_ ;  set  ex1 end=last;  if  tall  then  count_tall + 1 ;  if  last  then   do ;  if  count_tall  then do ; PROCESSING MACRO VARIABLES AT EXECUTION TIME WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ="Some students are taller than 63 inches";  end ;  else   do ;  %let  titl =  "None of the students are taller than 63 inches";  end ;  end ;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . User-Defined Macro Variables
; do else data   _null_ ;  set  ex1 end=last;  if  tall  then  count_tall + 1 ;  if  last  then   do ;  if  count_tall  then do ; end ; PROCESSING MACRO VARIABLES AT EXECUTION TIME WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK %let  titl =  "None of the students are taller than 63 inches";  end ;  end ;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . User-Defined Macro Variables   Titl  Some students are  taller than 63 inches
% ; do data   _null_ ;  set  ex1 end=last;  if  tall  then  count_tall + 1 ;  if  last  then   do ;  if  count_tall  then do ; end ;  else PROCESSING MACRO VARIABLES AT EXECUTION TIME WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK let  titl =  "None of the students are taller than 63 inches";  end ;  end ;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . User-Defined Macro Variables   Titl  Some students are  taller than 63 inches
titl let % data   _null_ ;  set  ex1 end=last;  if  tall  then  count_tall + 1 ;  if  last  then   do ;  if  count_tall  then do ; end ;  else do ; PROCESSING MACRO VARIABLES AT EXECUTION TIME WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK =  "None of the students are taller than 63 inches";  end ;  end ;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . User-Defined Macro Variables   Titl  Some students are  taller than 63 inches
let % ; data   _null_ ;  set  ex1 end=last;  if  tall  then  count_tall + 1 ;  if  last  then   do ;  if  count_tall  then do ; end ;  else do PROCESSING MACRO VARIABLES AT EXECUTION TIME WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK titl =  "None of the students are taller than 63 inches";  end ;  end ;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . User-Defined Macro Variables   Titl  Some students are  taller than 63 inches
; end data   _null_ ;  set  ex1 end=last;  if  tall  then  count_tall + 1 ;  if  last  then   do ;  if  count_tall  then do ; end ;  else do ; PROCESSING MACRO VARIABLES AT EXECUTION TIME WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK end ;  run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . User-Defined Macro Variables   Titl  None of the students are taller than 63 inches
data   _null_ ;  set  ex1 end=last;  if  tall  then  count_tall + 1 ;  if  last  then   do ;  if  count_tall  then do ; end ;  else do ;  end ;  end ;  run ; PROCESSING MACRO VARIABLES AT EXECUTION TIME WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE  19JUN06 SYSDAT  Monday SYSTIME  10:34 . . User-Defined Macro Variables   Titl  None of the students are taller than 63 inches
PROCESSING MACRO VARIABLES AT EXECUTION TIME Ex1: data   _null_ ; set  ex1 end=last; if  tall  then  count_tall + 1 ; if  last  then   do ; if  count_tall  then   do ; %let  titl = "Some students are taller than 63 inches"; end ; else   do ; %let  titl = "None of the students are taller than 63 inches"; end ; end ; run ; Here is what the program will look like when it is processed by the compiler  64 62 60 65 height 1 f Helen 4 0 f Mary 3 0 m Tom 2 1 m John 1 tall sex name
THE SYMPUT ROUTINE  ,[object Object],CALL SYMPUT  (MACRO-VARIABLE, VALUE); ,[object Object],[object Object],[object Object],[object Object]
THE SYMPUT ROUTINE  CALL SYMPUT  (MACRO-VARIABLE, VALUE); ,[object Object],‘ MACRO-VARIABLE’: Text enclosed in the quotation marks is the exact macro variable name ‘ VALUE’: The exact value that is assigned to the MACRO-VARIABLE
THE SYMPUT ROUTINE  data   _null_ ; set  ex1 end=last; if  tall  then  count_tall + 1 ; if  last  then   do ; if  count_tall  then   do ; call  symput( 'titl' ,  'Some students are taller than 63 inches' ); end ; else   do ; call  symput( 'titl' ,  'None of the students are taller than 63 inches' ); end ; end ; run ; ,[object Object]
THE SYMPUT ROUTINE  proc   print   data =ex1; title  &titl; run ; Some students are taller than 63 inches Obs  name  sex  height  tall 1  John  m  65  1 2  Tom  m  60  0 3  Mary  f  62  0 4  Helen  f  64  1
THE SYMPUT ROUTINE  CALL SYMPUT  (MACRO-VARIABLE, VALUE); ,[object Object],A DATA step variable; not in quotation marks ,[object Object],[object Object],[object Object]
THE SYMPUT ROUTINE  ,[object Object],Height: 64 62 60 65 height f Helen 4 f Mary 3 m Tom 2 m John 1 sex name 64 Helen_ht 62 Mary_ht 60 Tom_ht 65 John_ht Values Macro Variable Names
THE SYMPUT ROUTINE  data   _null_ ; set  height; if  name =  'John'   then   call  symput ( 'John_ht' ,  height); else   if  name =  'Tom'   then   call  symput ( 'Tom_ht' ,  height); else   if  name =  'Mary'   then   call  symput ( 'Mary_ht' ,  height); else   if  name =  'Helen'   then   call  symput ( 'Helen_ht' , height); run ; Height: HEIGHT is not in quotation marks 64 62 60 65 height f Helen 4 f Mary 3 m Tom 2 m John 1 sex name
THE SYMPUT ROUTINE  %put  macro variable John_ht: &John_ht; %put  macro variable Tom_ht: &Tom_ht; %put  macro variable Mary_ht: &Mary_ht; %put  macro variable Helen_ht: &Helen_ht; Height: 359  %put macro variable John_ht: &John_ht; macro variable John_ht:  65 360  %put macro variable Tom_ht: &Tom_ht; macro variable Tom_ht:  60 361  %put macro variable Mary_ht: &Mary_ht; macro variable Mary_ht:  62 362  %put macro variable Helen_ht: &Helen_ht; macro variable Helen_ht:  64 Log: 64 62 60 65 height f Helen 4 f Mary 3 m Tom 2 m John 1 sex name
THE SYMPUT ROUTINE  CALL SYMPUT  (MACRO-VARIABLE, VALUE); ,[object Object],A DATA step variable; not in quotation marks ,[object Object],[object Object]
THE SYMPUT ROUTINE  ,[object Object],Height: 64 62 60 65 height f Helen 4 f Mary 3 m Tom 2 m John 1 sex name 64 Helen 62 Mary 60 Tom 65 John Values Macro Variable Names
THE SYMPUT ROUTINE  Height: data   _null_ ; set  height; call  symput (name, height); run ; NAME is not in quotation marks 64 62 60 65 height f Helen 4 f Mary 3 m Tom 2 m John 1 sex name
THE SYMPUT ROUTINE  Height: %put  macro variable John: &John; %put  macro variable Tom: &Tom; %put  macro variable Mary: &Mary; %put  macro variable Helen: &Helen; 368  %put macro variable John: &John; macro variable John:  65 369  %put macro variable Tom: &Tom; macro variable Tom:  60 370  %put macro variable Mary: &Mary; macro variable Mary:  62 371  %put macro variable Helen: &Helen; macro variable Helen:  64 Log: Notice that “blanks” are part of the macro variables 64 62 60 65 height f Helen 4 f Mary 3 m Tom 2 m John 1 sex name
THE SYMPUT ROUTINE  CALL SYMPUT  (MACRO-VARIABLE, VALUE); ,[object Object],A DATA step expression A DATA step expression
THE SYMPUT ROUTINE  ,[object Object],Height: ,[object Object],64 62 60 65 height f Helen 4 f Mary 3 m Tom 2 m John 1 sex name 64 height_Helen 62 height_Mary 60 height_Tom 65 height_John Values Macro Variable Names
THE SYMPUT ROUTINE  Height: data   _null_ ; set  height; call  symput ( "height_"  ||name, trim(left(height))); run ; 64 62 60 65 height f Helen 4 f Mary 3 m Tom 2 m John 1 sex name
THE SYMPUT ROUTINE  Height: %put  macro variable height_John: &height_John; %put  macro variable height_Tom: &height_Tom; %put  macro variable height_Mary: &height_Mary; %put  macro variable height_Helen: &height_Helen; 411  %put macro variable height_John: &height_John; macro variable height_John: 65 412  %put macro variable height_Tom: &height_Tom; macro variable height_Tom: 60 413  %put macro variable height_Mary: &height_Mary; macro variable height_Mary: 62 414  %put macro variable height_Helen: &height_Helen; macro variable height_Helen: 64 Log: 64 62 60 65 height f Helen 4 f Mary 3 m Tom 2 m John 1 sex name
THE SYMPUTX ROUTINE  ,[object Object],[object Object],[object Object],data   _null_ ; set  height; call  symputx ( "height_"  ||name, height); run ;
THE SYMPUTX ROUTINE  %put  macro variable height_John: &height_John; %put  macro variable height_Tom: &height_Tom; %put  macro variable height_Mary: &height_Mary; %put  macro variable height_Helen: &height_Helen; 429  %put macro variable height_John: &height_John; macro variable height_John: 65 430  %put macro variable height_Tom: &height_Tom; macro variable height_Tom: 60 431  %put macro variable height_Mary: &height_Mary; macro variable height_Mary: 62 432  %put macro variable height_Helen: &height_Helen; macro variable height_Helen: 64 Log:
THE SYMPUTX ROUTINE  ,[object Object],CALL SYMPUTX  CALL SYMPUT  Does  not  write a note to the SAS log when the 2 nd  argument is numeric Writes a note to the SAS log when the 2 nd  argument is numeric Uses a field width of up to 32 characters for converting a numeric 2 nd  argument to characters Uses a field width of up to 12 characters for converting a numeric 2 nd  argument to characters Left-justifies both arguments and trims trailing blanks  Does not left-justify the arguments and trims trailing blanks from the first argument only Enables you to specify the symbol table  Does not enable you to specify the symbol table
PROCESSING MACRO VARIABLES DURING THE EXECUTION OF PROC SQL  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
PROCESSING MACRO VARIABLES DURING THE EXECUTION OF PROC SQL  ,[object Object],PROC SQL  <PRINT|NOPRINT>; SELECT  column1 <, column2, …> INTO  :macro-variable1 <, :macro-variable2, …> FROM  table |view <other clauses>; QUIT ; To select one or more columns from SQL table/view, you can specify column1, column2, … after the keyword SELECT
PROCESSING MACRO VARIABLES DURING THE EXECUTION OF PROC SQL  ,[object Object],PROC SQL  <PRINT|NOPRINT>; SELECT  column1 <, column2, …> INTO  :macro-variable1 <, :macro-variable2, …> FROM  table |view <other clauses>; QUIT ; Macro-variable1, macro-variable2 are the names of the macro variables that you are creating
PROCESSING MACRO VARIABLES DURING THE EXECUTION OF PROC SQL  ,[object Object],PROC SQL  <PRINT|NOPRINT>; SELECT  column1 <, column2, …> INTO  :macro-variable1 <, :macro-variable2, …> FROM  table |view <other clauses>; QUIT ; You must write colon(s) (:) before each of the macro variables
PROCESSING MACRO VARIABLES DURING THE EXECUTION OF PROC SQL  ,[object Object],PROC SQL  <PRINT|NOPRINT>; SELECT  column1 <, column2, …> INTO  :macro-variable1 <, :macro-variable2, …> FROM  table |view <other clauses>; QUIT ; The INTO clause does not trim the leading and trailing blanks of the macro variables
PROCESSING MACRO VARIABLES DURING THE EXECUTION OF PROC SQL  ,[object Object],PROC SQL  <PRINT|NOPRINT>; SELECT  column1 <, column2, …> INTO  :macro-variable1 <, :macro-variable2, …> FROM  table |view <other clauses>; QUIT ; To suppress display-output from PROC SQL, you can use the NOPRINT option
PROCESSING MACRO VARIABLES DURING THE EXECUTION OF PROC SQL  ,[object Object],[object Object],proc   sql   noprint ; select  mean(height)  into : mean_ht from  height; quit ; %put  macro variable mean_ht: &mean_ht; 523  %put macro variable mean_ht: &mean_ht; macro variable mean_ht:  62.75 Log:
PROCESSING MACRO VARIABLES DURING THE EXECUTION OF PROC SQL  ,[object Object],proc   means   data =height  noprint ; var  height; output   out =height_mean  mean =ht_mean; run ; data   _null_ ; set  height_mean; call  symputx( 'mean_ht1' , ht_mean); run ;
PROCESSING MACRO VARIABLES DURING THE EXECUTION OF PROC SQL  ,[object Object],data   _null_ ; set  height; if  name =  'John'   then   call  symput ( 'John_ht' ,  height); else   if  name =  'Tom'   then   call  symput ( 'Tom_ht' ,  height); else   if  name =  'Mary'   then   call  symput ( 'Mary_ht' ,  height); else   if  name =  'Helen'   then   call  symput ( 'Helen_ht' , height); run ; ,[object Object],proc   sql   noprint ; select  height  into : John_ht1  from  height where  name =  'John' ; select  height  into : Tom_ht1  from  height where  name =  'Tom' ; select  height  into : Mary_ht1  from  height where  name =  'Mary' ; select  height  into : Helen_ht1  from  height where  name =  'Helen' ; quit ;
PROCESSING MACRO VARIABLES DURING THE EXECUTION OF PROC SQL  ,[object Object],[object Object],PROC SQL  <PRINT|NOPRINT>; SELECT  column1 <, column2, …> INTO  :macro-variable1_1 -  :macro-variable1_n < NOTRIM> <, :macro-variable2_1 -  :macro-variable2_n < NOTRIM>, …> FROM  table |view <other clauses>; QUIT ;
PROCESSING MACRO VARIABLES DURING THE EXECUTION OF PROC SQL  PROC SQL  <PRINT|NOPRINT>; SELECT  column1 <, column2, …> INTO  :macro-variable1_1 -  :macro-variable1_n < NOTRIM> <, :macro-variable2_1 -  :macro-variable2_n < NOTRIM>, …> FROM  table |view <other clauses>; QUIT ; into :name1 - :name4,  :height1 - :height4 64 62 60 65 height f Helen 4 f Mary 3 m Tom 2 m John 1 sex name name1 name2 name3 name4 height1 height2 height3 height4
PROCESSING MACRO VARIABLES DURING THE EXECUTION OF PROC SQL  PROC SQL  <PRINT|NOPRINT>; SELECT  column1 <, column2, …> INTO  :macro-variable1_1 -  :macro-variable1_n < NOTRIM> <, :macro-variable2_1 -  :macro-variable2_n < NOTRIM>, …> FROM  table |view <other clauses>; QUIT ; ,[object Object],[object Object]
PROCESSING MACRO VARIABLES DURING THE EXECUTION OF PROC SQL  ,[object Object],proc   sql   noprint ; select  name, height  into  :name1 - :name4,    :height1 - :height4 from  height; quit ; %put  macro variable name1: &name1; %put  macro variable name2: &name2; %put  macro variable name3: &name3; %put  macro variable name4: &name4; %put  macro variable height1: &height1; %put  macro variable height2: &height2; %put  macro variable height3: &height3; %put  macro variable height4: &height4;
PROCESSING MACRO VARIABLES DURING THE EXECUTION OF PROC SQL  ,[object Object],663  %put macro variable name1: &name1; macro variable name1: John 664  %put macro variable name2: &name2; macro variable name2: Tom 665  %put macro variable name3: &name3; macro variable name3: Mary 666  %put macro variable name4: &name4; macro variable name4: Helen 667  %put macro variable height1: &height1; macro variable height1: 65 668  %put macro variable height2: &height2; macro variable height2: 60 669  %put macro variable height3: &height3; macro variable height3: 62 670  %put macro variable height4: &height4; macro variable height4: 64
PROCESSING MACRO VARIABLES DURING THE EXECUTION OF PROC SQL  ,[object Object],[object Object],[object Object],[object Object]
PROCESSING MACRO VARIABLES DURING THE EXECUTION OF PROC SQL  ,[object Object],PROC SQL  <PRINT|NOPRINT>; SELECT  column1 <, column2, …>  INTO  :macro-variable1  SEPARATED  BY ‘delimiter1’ <, :macro-variable2  SEPARATED  BY ‘delimiter2’, …> FROM  table |view <other clauses>; QUIT ; Delimiter1 is used to separate all the values in the column and must be enclosed in quotation marks
PROCESSING MACRO VARIABLES DURING THE EXECUTION OF PROC SQL  ,[object Object],Macro Variable Value  NAMELIST John Tom Mary Helen HEIGHTLIST 65,60,62,64  64 62 60 65 height f Helen 4 f Mary 3 m Tom 2 m John 1 sex name
PROCESSING MACRO VARIABLES DURING THE EXECUTION OF PROC SQL  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],871  %put macro variable namelist: &namelist; macro variable namelist: John Tom Mary Helen 872  %put macro variable heightlist: &heightlist; macro variable heightlist: 65,60,62,64
CONCLUSION ,[object Object],[object Object],[object Object],[object Object]
REFERENCES ,[object Object],[object Object]
ACKNOWLEDGEMENT  ,[object Object]
CONTACT INFORMATION ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Contenu connexe

Tendances

Find Anything In Your APEX App - Fuzzy Search with Oracle Text
Find Anything In Your APEX App - Fuzzy Search with Oracle TextFind Anything In Your APEX App - Fuzzy Search with Oracle Text
Find Anything In Your APEX App - Fuzzy Search with Oracle TextCarsten Czarski
 
MemVerge: The Software Stack for CXL Environments
MemVerge: The Software Stack for CXL EnvironmentsMemVerge: The Software Stack for CXL Environments
MemVerge: The Software Stack for CXL EnvironmentsMemory Fabric Forum
 
Introduction to FreeRTOS
Introduction to FreeRTOSIntroduction to FreeRTOS
Introduction to FreeRTOSICS
 
Open Source for the 4th Industrial Revolution
Open Source for the 4th Industrial RevolutionOpen Source for the 4th Industrial Revolution
Open Source for the 4th Industrial RevolutionLiz Warner
 
Developing safety autonomous driving solutions based on the adaptive AUTOSAR ...
Developing safety autonomous driving solutions based on the adaptive AUTOSAR ...Developing safety autonomous driving solutions based on the adaptive AUTOSAR ...
Developing safety autonomous driving solutions based on the adaptive AUTOSAR ...Andrei Kholodnyi
 
ISO/IEC 27701 vs. ISO/IEC 27001 vs. NIST: Essential Things You Need to Know
ISO/IEC 27701 vs. ISO/IEC 27001 vs. NIST: Essential Things You Need to KnowISO/IEC 27701 vs. ISO/IEC 27001 vs. NIST: Essential Things You Need to Know
ISO/IEC 27701 vs. ISO/IEC 27001 vs. NIST: Essential Things You Need to KnowPECB
 
Automotive functional safety iso 26262 training bootcamp 2019
Automotive functional safety iso 26262 training bootcamp 2019Automotive functional safety iso 26262 training bootcamp 2019
Automotive functional safety iso 26262 training bootcamp 2019Tonex
 
Introduction to Real-Time Operating Systems
Introduction to Real-Time Operating SystemsIntroduction to Real-Time Operating Systems
Introduction to Real-Time Operating Systemscoolmirza143
 
XMpLant delivering interoperability
XMpLant delivering interoperabilityXMpLant delivering interoperability
XMpLant delivering interoperabilityTaiheon Choi
 
Csw2017 bazhaniuk exploring_yoursystemdeeper_updated
Csw2017 bazhaniuk exploring_yoursystemdeeper_updatedCsw2017 bazhaniuk exploring_yoursystemdeeper_updated
Csw2017 bazhaniuk exploring_yoursystemdeeper_updatedCanSecWest
 
System Device Tree and Lopper: Concrete Examples - ELC NA 2022
System Device Tree and Lopper: Concrete Examples - ELC NA 2022System Device Tree and Lopper: Concrete Examples - ELC NA 2022
System Device Tree and Lopper: Concrete Examples - ELC NA 2022Stefano Stabellini
 
How Airlines Can Use Location Intelligence for Split Loyalty Analysis & More
How Airlines Can Use Location Intelligence for Split Loyalty Analysis & MoreHow Airlines Can Use Location Intelligence for Split Loyalty Analysis & More
How Airlines Can Use Location Intelligence for Split Loyalty Analysis & MoreSkyhook
 
L1_Introduction.pptx
L1_Introduction.pptxL1_Introduction.pptx
L1_Introduction.pptxStevenTharp2
 
Webinar Presentation- Typical Challenges Faced by Tier 1s in AUTOSAR Tooling
Webinar Presentation- Typical Challenges Faced by Tier 1s in AUTOSAR ToolingWebinar Presentation- Typical Challenges Faced by Tier 1s in AUTOSAR Tooling
Webinar Presentation- Typical Challenges Faced by Tier 1s in AUTOSAR ToolingKPIT
 
Arm corrected ppt
Arm corrected pptArm corrected ppt
Arm corrected pptanish jagan
 
Linux Kernel Startup Code In Embedded Linux
Linux    Kernel    Startup  Code In  Embedded  LinuxLinux    Kernel    Startup  Code In  Embedded  Linux
Linux Kernel Startup Code In Embedded LinuxEmanuele Bonanni
 
ARM® Cortex M Boot & CMSIS Part 1-3
ARM® Cortex M Boot & CMSIS Part 1-3ARM® Cortex M Boot & CMSIS Part 1-3
ARM® Cortex M Boot & CMSIS Part 1-3Raahul Raghavan
 
Z4R: Intro to Storage and DFSMS for z/OS
Z4R: Intro to Storage and DFSMS for z/OSZ4R: Intro to Storage and DFSMS for z/OS
Z4R: Intro to Storage and DFSMS for z/OSTony Pearson
 

Tendances (20)

How to choose an RTOS?
How to choose an RTOS?How to choose an RTOS?
How to choose an RTOS?
 
Find Anything In Your APEX App - Fuzzy Search with Oracle Text
Find Anything In Your APEX App - Fuzzy Search with Oracle TextFind Anything In Your APEX App - Fuzzy Search with Oracle Text
Find Anything In Your APEX App - Fuzzy Search with Oracle Text
 
MemVerge: The Software Stack for CXL Environments
MemVerge: The Software Stack for CXL EnvironmentsMemVerge: The Software Stack for CXL Environments
MemVerge: The Software Stack for CXL Environments
 
Introduction to FreeRTOS
Introduction to FreeRTOSIntroduction to FreeRTOS
Introduction to FreeRTOS
 
Open Source for the 4th Industrial Revolution
Open Source for the 4th Industrial RevolutionOpen Source for the 4th Industrial Revolution
Open Source for the 4th Industrial Revolution
 
Developing safety autonomous driving solutions based on the adaptive AUTOSAR ...
Developing safety autonomous driving solutions based on the adaptive AUTOSAR ...Developing safety autonomous driving solutions based on the adaptive AUTOSAR ...
Developing safety autonomous driving solutions based on the adaptive AUTOSAR ...
 
ISO/IEC 27701 vs. ISO/IEC 27001 vs. NIST: Essential Things You Need to Know
ISO/IEC 27701 vs. ISO/IEC 27001 vs. NIST: Essential Things You Need to KnowISO/IEC 27701 vs. ISO/IEC 27001 vs. NIST: Essential Things You Need to Know
ISO/IEC 27701 vs. ISO/IEC 27001 vs. NIST: Essential Things You Need to Know
 
Automotive functional safety iso 26262 training bootcamp 2019
Automotive functional safety iso 26262 training bootcamp 2019Automotive functional safety iso 26262 training bootcamp 2019
Automotive functional safety iso 26262 training bootcamp 2019
 
Introduction to Real-Time Operating Systems
Introduction to Real-Time Operating SystemsIntroduction to Real-Time Operating Systems
Introduction to Real-Time Operating Systems
 
XMpLant delivering interoperability
XMpLant delivering interoperabilityXMpLant delivering interoperability
XMpLant delivering interoperability
 
Csw2017 bazhaniuk exploring_yoursystemdeeper_updated
Csw2017 bazhaniuk exploring_yoursystemdeeper_updatedCsw2017 bazhaniuk exploring_yoursystemdeeper_updated
Csw2017 bazhaniuk exploring_yoursystemdeeper_updated
 
System Device Tree and Lopper: Concrete Examples - ELC NA 2022
System Device Tree and Lopper: Concrete Examples - ELC NA 2022System Device Tree and Lopper: Concrete Examples - ELC NA 2022
System Device Tree and Lopper: Concrete Examples - ELC NA 2022
 
How Airlines Can Use Location Intelligence for Split Loyalty Analysis & More
How Airlines Can Use Location Intelligence for Split Loyalty Analysis & MoreHow Airlines Can Use Location Intelligence for Split Loyalty Analysis & More
How Airlines Can Use Location Intelligence for Split Loyalty Analysis & More
 
L1_Introduction.pptx
L1_Introduction.pptxL1_Introduction.pptx
L1_Introduction.pptx
 
Webinar Presentation- Typical Challenges Faced by Tier 1s in AUTOSAR Tooling
Webinar Presentation- Typical Challenges Faced by Tier 1s in AUTOSAR ToolingWebinar Presentation- Typical Challenges Faced by Tier 1s in AUTOSAR Tooling
Webinar Presentation- Typical Challenges Faced by Tier 1s in AUTOSAR Tooling
 
Arm corrected ppt
Arm corrected pptArm corrected ppt
Arm corrected ppt
 
Linux Kernel Startup Code In Embedded Linux
Linux    Kernel    Startup  Code In  Embedded  LinuxLinux    Kernel    Startup  Code In  Embedded  Linux
Linux Kernel Startup Code In Embedded Linux
 
ARM® Cortex M Boot & CMSIS Part 1-3
ARM® Cortex M Boot & CMSIS Part 1-3ARM® Cortex M Boot & CMSIS Part 1-3
ARM® Cortex M Boot & CMSIS Part 1-3
 
Z4R: Intro to Storage and DFSMS for z/OS
Z4R: Intro to Storage and DFSMS for z/OSZ4R: Intro to Storage and DFSMS for z/OS
Z4R: Intro to Storage and DFSMS for z/OS
 
EMC report.pdf
EMC report.pdfEMC report.pdf
EMC report.pdf
 

En vedette

SAS Macros part 2
SAS Macros part 2SAS Macros part 2
SAS Macros part 2venkatam
 
SAS Macros part 1
SAS Macros part 1SAS Macros part 1
SAS Macros part 1venkatam
 
SAS Macro practice
SAS Macro practiceSAS Macro practice
SAS Macro practicePing Yin
 
SAS Macros part 3
SAS Macros part 3SAS Macros part 3
SAS Macros part 3venkatam
 
Habits of Effective SAS Programmers
Habits of Effective SAS ProgrammersHabits of Effective SAS Programmers
Habits of Effective SAS ProgrammersSunil Gupta
 
Market Basket Analysis in SAS
Market Basket Analysis in SASMarket Basket Analysis in SAS
Market Basket Analysis in SASAndrew Kramer
 
Motivating Clinical Sas Programmers
Motivating Clinical Sas ProgrammersMotivating Clinical Sas Programmers
Motivating Clinical Sas ProgrammersDaniel Boisvert
 
Introduction to clinical sas programming
Introduction to clinical sas programmingIntroduction to clinical sas programming
Introduction to clinical sas programmingray4hz
 

En vedette (9)

SAS Macros part 2
SAS Macros part 2SAS Macros part 2
SAS Macros part 2
 
SAS Macros part 1
SAS Macros part 1SAS Macros part 1
SAS Macros part 1
 
SAS Macros
SAS MacrosSAS Macros
SAS Macros
 
SAS Macro practice
SAS Macro practiceSAS Macro practice
SAS Macro practice
 
SAS Macros part 3
SAS Macros part 3SAS Macros part 3
SAS Macros part 3
 
Habits of Effective SAS Programmers
Habits of Effective SAS ProgrammersHabits of Effective SAS Programmers
Habits of Effective SAS Programmers
 
Market Basket Analysis in SAS
Market Basket Analysis in SASMarket Basket Analysis in SAS
Market Basket Analysis in SAS
 
Motivating Clinical Sas Programmers
Motivating Clinical Sas ProgrammersMotivating Clinical Sas Programmers
Motivating Clinical Sas Programmers
 
Introduction to clinical sas programming
Introduction to clinical sas programmingIntroduction to clinical sas programming
Introduction to clinical sas programming
 

Similaire à When best to use the %let statement, the symput routine, or the into clause to create macro variables

SAS macro processing vs with out macro processing
SAS macro processing vs with out macro processingSAS macro processing vs with out macro processing
SAS macro processing vs with out macro processingSAYAN DAS
 
Sas macros part 4.1
Sas macros part 4.1Sas macros part 4.1
Sas macros part 4.1venkatam
 
SAS Macros part 4.1
SAS Macros part 4.1SAS Macros part 4.1
SAS Macros part 4.1venkatam
 
DBA Fundamentals Group: Continuous SQL with Kafka and Flink
DBA Fundamentals Group: Continuous SQL with Kafka and FlinkDBA Fundamentals Group: Continuous SQL with Kafka and Flink
DBA Fundamentals Group: Continuous SQL with Kafka and FlinkTimothy Spann
 
Securing Java EE Web Apps
Securing Java EE Web AppsSecuring Java EE Web Apps
Securing Java EE Web AppsFrank Kim
 
Prog1 chap1 and chap 2
Prog1 chap1 and chap 2Prog1 chap1 and chap 2
Prog1 chap1 and chap 2rowensCap
 
30 5 Database Jdbc
30 5 Database Jdbc30 5 Database Jdbc
30 5 Database Jdbcphanleson
 
Top 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesCarol McDonald
 
ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...
ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...
ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...Paul Brebner
 
Dataservices: Processing (Big) Data the Microservice Way
Dataservices: Processing (Big) Data the Microservice WayDataservices: Processing (Big) Data the Microservice Way
Dataservices: Processing (Big) Data the Microservice WayQAware GmbH
 
How to Improve the Observability of Apache Cassandra and Kafka applications...
How to Improve the Observability of Apache Cassandra and Kafka applications...How to Improve the Observability of Apache Cassandra and Kafka applications...
How to Improve the Observability of Apache Cassandra and Kafka applications...Paul Brebner
 
Kamaelia Protocol Walkthrough
Kamaelia Protocol WalkthroughKamaelia Protocol Walkthrough
Kamaelia Protocol Walkthroughkamaelian
 
Interoperable Web Services with JAX-WS
Interoperable Web Services with JAX-WSInteroperable Web Services with JAX-WS
Interoperable Web Services with JAX-WSCarol McDonald
 
Continuous Application with Structured Streaming 2.0
Continuous Application with Structured Streaming 2.0Continuous Application with Structured Streaming 2.0
Continuous Application with Structured Streaming 2.0Anyscale
 

Similaire à When best to use the %let statement, the symput routine, or the into clause to create macro variables (20)

SAS macro processing vs with out macro processing
SAS macro processing vs with out macro processingSAS macro processing vs with out macro processing
SAS macro processing vs with out macro processing
 
Sas macros part 4.1
Sas macros part 4.1Sas macros part 4.1
Sas macros part 4.1
 
SAS Macros part 4.1
SAS Macros part 4.1SAS Macros part 4.1
SAS Macros part 4.1
 
DBA Fundamentals Group: Continuous SQL with Kafka and Flink
DBA Fundamentals Group: Continuous SQL with Kafka and FlinkDBA Fundamentals Group: Continuous SQL with Kafka and Flink
DBA Fundamentals Group: Continuous SQL with Kafka and Flink
 
Securing Java EE Web Apps
Securing Java EE Web AppsSecuring Java EE Web Apps
Securing Java EE Web Apps
 
SAS Macro
SAS MacroSAS Macro
SAS Macro
 
Combres
CombresCombres
Combres
 
Prog1 chap1 and chap 2
Prog1 chap1 and chap 2Prog1 chap1 and chap 2
Prog1 chap1 and chap 2
 
30 5 Database Jdbc
30 5 Database Jdbc30 5 Database Jdbc
30 5 Database Jdbc
 
Top 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security Vulnerabilities
 
Goto devoxx
Goto devoxxGoto devoxx
Goto devoxx
 
ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...
ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...
ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...
 
Dataservices: Processing (Big) Data the Microservice Way
Dataservices: Processing (Big) Data the Microservice WayDataservices: Processing (Big) Data the Microservice Way
Dataservices: Processing (Big) Data the Microservice Way
 
Ss4
Ss4Ss4
Ss4
 
How to Improve the Observability of Apache Cassandra and Kafka applications...
How to Improve the Observability of Apache Cassandra and Kafka applications...How to Improve the Observability of Apache Cassandra and Kafka applications...
How to Improve the Observability of Apache Cassandra and Kafka applications...
 
Kamaelia Protocol Walkthrough
Kamaelia Protocol WalkthroughKamaelia Protocol Walkthrough
Kamaelia Protocol Walkthrough
 
Cpcs302 1
Cpcs302  1Cpcs302  1
Cpcs302 1
 
Interoperable Web Services with JAX-WS
Interoperable Web Services with JAX-WSInteroperable Web Services with JAX-WS
Interoperable Web Services with JAX-WS
 
2. introduction
2. introduction2. introduction
2. introduction
 
Continuous Application with Structured Streaming 2.0
Continuous Application with Structured Streaming 2.0Continuous Application with Structured Streaming 2.0
Continuous Application with Structured Streaming 2.0
 

Dernier

Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 

Dernier (20)

Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 

When best to use the %let statement, the symput routine, or the into clause to create macro variables

  • 1. When Best to Use the %LET Statement, the SYMPUT Routine, or the INTO Clause to Create Macro Variables Arthur Li Department of Information Science City of Hope Comprehensive Cancer Center Duarte, CA
  • 2. INTRODUCTION DATA Step PROC Steps SAS Macro Facility BASE SAS Use to generate SAS codes more… PROC SQL
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14. data UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ex1; set height; tall = height > 63 ; run ;
  • 15. ex1 data UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ; set height; tall = height > 63 ; run ;
  • 16. ; ex1 data UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK set height; tall = height > 63 ; run ;
  • 17. set ; ex1 data UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK height; tall = height > 63 ; run ;
  • 18. height set ; data ex1 UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ; tall = height > 63 ; run ;
  • 19. ; height set data ex1; UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK tall = height > 63 ; run ;
  • 20. tall ; height data ex1; set UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK = height > 63 ; run ;
  • 21. = tall ; data ex1; set height UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK height > 63 ; run ;
  • 22. height = tall data ex1; set height; UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK > 63 ; run ;
  • 23. > height = data ex1; set height; tall UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK 63 ; run ;
  • 24. 63 > height data ex1; set height; tall = UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ; run ;
  • 25. ; 63 > data ex1; set height; tall = height UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK run ;
  • 26. run ; 63 data ex1; set height; tall = height > UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ;
  • 27. ; run ; data ex1; set height; tall = height > 63 UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK
  • 28. ; run data ex1; set height; tall = height > 63 ; UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK
  • 29. ; data ex1; set height; tall = height > 63 ; run UNDERSTANDING SAS PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK
  • 30.
  • 31. UNDERSTANDING SAS PROCESSING Types of Token Contains … Examples Literal Characters enclosed in quotation marks “ John” ‘John’ Numerals including decimals, E-notation, date, time, datetime constants, and hexadecimal constants 555 ‘ 01mar2010’d 30e4 Number Characters that begin with a letter or underscore and that continues with underscores, letters, or numbers. A period can sometimes be part of a name _n_ means dollar9.2 Descending Name Characters other than a letter, number, or underscore that have a special meaning to the SAS system Special character / + % & . ;
  • 32.
  • 33.
  • 34. % MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK let ht =63; data ex1; set height; tall =height >&ht; run ; MACRO PROCESSOR
  • 35.
  • 36. ht let % MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK =63; data ex1; set height; tall =height >&ht; run ; MACRO PROCESSOR
  • 37. = ht let % MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK 63; data ex1; set height; tall =height >&ht; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables
  • 38. ; 63 = ht MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK data ex1; set height; tall =height >&ht; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables
  • 39. data ; 63 = MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ex1; set height; tall =height >&ht; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht
  • 40.
  • 41. ; ex1 data MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK set height; tall =height >&ht; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 42. set ; ex1 data MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK height; tall =height >&ht; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 43. height set ; data ex1 MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ; tall =height >&ht; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 44. ; height set data ex1; MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK tall =height >&ht; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 45. tall ; height data ex1; set MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK =height >&ht; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 46. = tall ; data ex1; set height MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK height >&ht; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 47. height = tall data ex1; set Height; MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK >&ht; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 48. > height = data ex1; set height; tall MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK &ht; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 49. & > height data ex1; set height; tall = MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ht; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 50.
  • 51. ht & data ex1; set height; tall = Height > MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 52. ht data ex1; set height; tall = Height > MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 53.
  • 54. ht data ex1; set height; tall = Height > 63 MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 55. data ex1; set height; tall = Height > 63 MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 56. data ex1; set height; tall = Height > MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK 63 ; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 57. 63 data ex1; set height; tall = Height > MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 58. ; 63 data ex1; set height; tall = Height > MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 59. run ; 63 data ex1; set height; tall = Height > MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 60. ; run ; data ex1; set height; tall = Height > 63 MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 61. ; run data ex1; set height; tall = Height > 63 ; MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 62. ; data ex1; set height; tall = Height > 63 ; run MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 63. data ex1; set height; tall = Height > 63 ; run; MACRO PROCESSING WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . . User-Defined Macro Variables ht 63
  • 64.
  • 65.
  • 66. PROCESSING MACRO VARIABLES AT EXECUTION TIME Ex1: data _null_ ; set ex1 end=last; if tall then count_tall + 1 ; if last then do ; if count_tall then do ; %let titl = &quot;Some students are taller than 63 inches&quot;; end ; else do ; %let titl = &quot;None of the students are taller than 63 inches&quot;; end ; end ; run ; 64 62 60 65 height 1 f Helen 4 0 f Mary 3 0 m Tom 2 1 m John 1 tall sex name
  • 67. PROCESSING MACRO VARIABLES AT EXECUTION TIME Ex1: proc print data =ex1; title &titl; run ; None of the students are taller than 63 inches Obs name sex height tall 1 John m 65 1 2 Tom m 60 0 3 Mary f 62 0 4 Helen f 64 1 64 62 60 65 height 1 f Helen 4 0 f Mary 3 0 m Tom 2 1 m John 1 tall sex name
  • 68. PROCESSING MACRO VARIABLES AT EXECUTION TIME WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK data _null_ ; set ex1 end=last; if tall then count_tall + 1 ; if last then do ; if count_tall then do ; %let titl =&quot;Some students are taller than 63 inches&quot;; end ; else do ; %let titl = &quot;None of the students are taller than 63 inches&quot;; end ; end ; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . User-Defined Macro Variables
  • 69. titl let % data _null_ ; set ex1 end=last; if tall then count_tall + 1 ; if last then do ; if count_tall then do ; PROCESSING MACRO VARIABLES AT EXECUTION TIME WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK =&quot;Some students are taller than 63 inches&quot;; end ; else do ; %let titl = &quot;None of the students are taller than 63 inches&quot;; end ; end ; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . User-Defined Macro Variables
  • 70. ; do else data _null_ ; set ex1 end=last; if tall then count_tall + 1 ; if last then do ; if count_tall then do ; end ; PROCESSING MACRO VARIABLES AT EXECUTION TIME WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK %let titl = &quot;None of the students are taller than 63 inches&quot;; end ; end ; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . User-Defined Macro Variables Titl Some students are taller than 63 inches
  • 71. % ; do data _null_ ; set ex1 end=last; if tall then count_tall + 1 ; if last then do ; if count_tall then do ; end ; else PROCESSING MACRO VARIABLES AT EXECUTION TIME WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK let titl = &quot;None of the students are taller than 63 inches&quot;; end ; end ; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . User-Defined Macro Variables Titl Some students are taller than 63 inches
  • 72. titl let % data _null_ ; set ex1 end=last; if tall then count_tall + 1 ; if last then do ; if count_tall then do ; end ; else do ; PROCESSING MACRO VARIABLES AT EXECUTION TIME WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK = &quot;None of the students are taller than 63 inches&quot;; end ; end ; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . User-Defined Macro Variables Titl Some students are taller than 63 inches
  • 73. let % ; data _null_ ; set ex1 end=last; if tall then count_tall + 1 ; if last then do ; if count_tall then do ; end ; else do PROCESSING MACRO VARIABLES AT EXECUTION TIME WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK titl = &quot;None of the students are taller than 63 inches&quot;; end ; end ; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . User-Defined Macro Variables Titl Some students are taller than 63 inches
  • 74. ; end data _null_ ; set ex1 end=last; if tall then count_tall + 1 ; if last then do ; if count_tall then do ; end ; else do ; PROCESSING MACRO VARIABLES AT EXECUTION TIME WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK end ; run ; MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . User-Defined Macro Variables Titl None of the students are taller than 63 inches
  • 75. data _null_ ; set ex1 end=last; if tall then count_tall + 1 ; if last then do ; if count_tall then do ; end ; else do ; end ; end ; run ; PROCESSING MACRO VARIABLES AT EXECUTION TIME WORD SCANNER TOKENNIZER DETERMINE DESTINATION COMPILER INPUT STACK MACRO PROCESSOR GLOBAL SYMBOL TABLE SAS Automatic Macro Variables SYSDATE 19JUN06 SYSDAT Monday SYSTIME 10:34 . . User-Defined Macro Variables Titl None of the students are taller than 63 inches
  • 76. PROCESSING MACRO VARIABLES AT EXECUTION TIME Ex1: data _null_ ; set ex1 end=last; if tall then count_tall + 1 ; if last then do ; if count_tall then do ; %let titl = &quot;Some students are taller than 63 inches&quot;; end ; else do ; %let titl = &quot;None of the students are taller than 63 inches&quot;; end ; end ; run ; Here is what the program will look like when it is processed by the compiler 64 62 60 65 height 1 f Helen 4 0 f Mary 3 0 m Tom 2 1 m John 1 tall sex name
  • 77.
  • 78.
  • 79.
  • 80. THE SYMPUT ROUTINE proc print data =ex1; title &titl; run ; Some students are taller than 63 inches Obs name sex height tall 1 John m 65 1 2 Tom m 60 0 3 Mary f 62 0 4 Helen f 64 1
  • 81.
  • 82.
  • 83. THE SYMPUT ROUTINE data _null_ ; set height; if name = 'John' then call symput ( 'John_ht' , height); else if name = 'Tom' then call symput ( 'Tom_ht' , height); else if name = 'Mary' then call symput ( 'Mary_ht' , height); else if name = 'Helen' then call symput ( 'Helen_ht' , height); run ; Height: HEIGHT is not in quotation marks 64 62 60 65 height f Helen 4 f Mary 3 m Tom 2 m John 1 sex name
  • 84. THE SYMPUT ROUTINE %put macro variable John_ht: &John_ht; %put macro variable Tom_ht: &Tom_ht; %put macro variable Mary_ht: &Mary_ht; %put macro variable Helen_ht: &Helen_ht; Height: 359 %put macro variable John_ht: &John_ht; macro variable John_ht: 65 360 %put macro variable Tom_ht: &Tom_ht; macro variable Tom_ht: 60 361 %put macro variable Mary_ht: &Mary_ht; macro variable Mary_ht: 62 362 %put macro variable Helen_ht: &Helen_ht; macro variable Helen_ht: 64 Log: 64 62 60 65 height f Helen 4 f Mary 3 m Tom 2 m John 1 sex name
  • 85.
  • 86.
  • 87. THE SYMPUT ROUTINE Height: data _null_ ; set height; call symput (name, height); run ; NAME is not in quotation marks 64 62 60 65 height f Helen 4 f Mary 3 m Tom 2 m John 1 sex name
  • 88. THE SYMPUT ROUTINE Height: %put macro variable John: &John; %put macro variable Tom: &Tom; %put macro variable Mary: &Mary; %put macro variable Helen: &Helen; 368 %put macro variable John: &John; macro variable John: 65 369 %put macro variable Tom: &Tom; macro variable Tom: 60 370 %put macro variable Mary: &Mary; macro variable Mary: 62 371 %put macro variable Helen: &Helen; macro variable Helen: 64 Log: Notice that “blanks” are part of the macro variables 64 62 60 65 height f Helen 4 f Mary 3 m Tom 2 m John 1 sex name
  • 89.
  • 90.
  • 91. THE SYMPUT ROUTINE Height: data _null_ ; set height; call symput ( &quot;height_&quot; ||name, trim(left(height))); run ; 64 62 60 65 height f Helen 4 f Mary 3 m Tom 2 m John 1 sex name
  • 92. THE SYMPUT ROUTINE Height: %put macro variable height_John: &height_John; %put macro variable height_Tom: &height_Tom; %put macro variable height_Mary: &height_Mary; %put macro variable height_Helen: &height_Helen; 411 %put macro variable height_John: &height_John; macro variable height_John: 65 412 %put macro variable height_Tom: &height_Tom; macro variable height_Tom: 60 413 %put macro variable height_Mary: &height_Mary; macro variable height_Mary: 62 414 %put macro variable height_Helen: &height_Helen; macro variable height_Helen: 64 Log: 64 62 60 65 height f Helen 4 f Mary 3 m Tom 2 m John 1 sex name
  • 93.
  • 94. THE SYMPUTX ROUTINE %put macro variable height_John: &height_John; %put macro variable height_Tom: &height_Tom; %put macro variable height_Mary: &height_Mary; %put macro variable height_Helen: &height_Helen; 429 %put macro variable height_John: &height_John; macro variable height_John: 65 430 %put macro variable height_Tom: &height_Tom; macro variable height_Tom: 60 431 %put macro variable height_Mary: &height_Mary; macro variable height_Mary: 62 432 %put macro variable height_Helen: &height_Helen; macro variable height_Helen: 64 Log:
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104.
  • 105.
  • 106. PROCESSING MACRO VARIABLES DURING THE EXECUTION OF PROC SQL PROC SQL <PRINT|NOPRINT>; SELECT column1 <, column2, …> INTO :macro-variable1_1 - :macro-variable1_n < NOTRIM> <, :macro-variable2_1 - :macro-variable2_n < NOTRIM>, …> FROM table |view <other clauses>; QUIT ; into :name1 - :name4, :height1 - :height4 64 62 60 65 height f Helen 4 f Mary 3 m Tom 2 m John 1 sex name name1 name2 name3 name4 height1 height2 height3 height4
  • 107.
  • 108.
  • 109.
  • 110.
  • 111.
  • 112.
  • 113.
  • 114.
  • 115.
  • 116.
  • 117.