I want to create/assign macro variables by adding and substracting variables in the dataset. Any suggestions would be appreciated. Thank you. -- George The code and dataset are attached. The code is: libname sasdb "C:\grezek\CRE CECL" ;data _null_ ; call symputx('d1','2016Q4'); call symputx('d2','2017Q1'); call symputx('d3','2017Q2'); call symputx('d4','2017Q3'); call symputx('d5','2017Q4'); call symputx('d6','2018Q1'); call symputx('d7','2018Q2'); call symputx('d8','2018Q3'); call symputx('d9','2018Q4'); call symputx('d10','2019Q1'); options symbolgen macrogen mprint ; %macro amort ; %do i = 1 %to 10 ; %let amort2_&&d&i = %sysevalf(amort_&&d&i.. + Net_financial_amount_&&d&i.. - Net_financial_amount_next_&&d&i..) ; %end ; run ; %mend ; run ; data sasdb.header_amort3 ; set sasdb.header_amort2 ; %amort ; run ; The log is (although I've tried quite of number of alternative, none seem to make the macro variable resolve to numbers): 83 libname sasdb "C:\grezek\CRE CECL" ; NOTE: Libref SASDB was successfully assigned as follows: Engine: V9 Physical Name: C:\grezek\CRE CECL 83 ! data _null_ ; 84 call symputx('d1','2016Q4'); 85 call symputx('d2','2017Q1'); 86 call symputx('d3','2017Q2'); 87 call symputx('d4','2017Q3'); 88 call symputx('d5','2017Q4'); 89 call symputx('d6','2018Q1'); 90 call symputx('d7','2018Q2'); 91 call symputx('d8','2018Q3'); 92 call symputx('d9','2018Q4'); 93 call symputx('d10','2019Q1'); 94 options symbolgen macrogen mprint ; 95 96 %macro amort ; 97 98 %do i = 1 %to 10 ; 99 %let amort2_&&d&i = %sysevalf(amort_&&d&i.. + Net_financial_amount_&&d&i.. - 99 ! Net_financial_amount_next_&&d&i..) ; 100 %end ; 101 run ; 102 %mend ; 103 run ; NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 104 105 data sasdb.header_amort3 ; 106 set sasdb.header_amort2 ; 107 108 %amort ; SYMBOLGEN: && resolves to &. SYMBOLGEN: Macro variable I resolves to 1 SYMBOLGEN: Macro variable D1 resolves to 2016Q4 SYMBOLGEN: && resolves to &. SYMBOLGEN: Macro variable I resolves to 1 SYMBOLGEN: Macro variable D1 resolves to 2016Q4 SYMBOLGEN: && resolves to &. SYMBOLGEN: Macro variable I resolves to 1 SYMBOLGEN: Macro variable D1 resolves to 2016Q4 SYMBOLGEN: && resolves to &. SYMBOLGEN: Macro variable I resolves to 1 SYMBOLGEN: Macro variable D1 resolves to 2016Q4 ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: amort_2016Q4 + Net_financial_amount_2016Q4 - Net_financial_amount_next_2016Q4 ERROR: The macro AMORT will stop executing. 109 run ; NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set SASDB.HEADER_AMORT3 may be incomplete. When this step was stopped there were 0 observations and 28 variables. WARNING: Data set SASDB.HEADER_AMORT3 was not replaced because this step was stopped. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds
... View more