Hi all,
I'm using SAS on Unix, that's the reason for the line numbers on the side. I'm using a nested do loop in macro and the code is giving me a couple unexpected lines right at the end. I'm not sure where they're coming from, but apparently my first counter variable, i, is causing a couple extra lines to generate, which is messing with the execution, causing the observations to be zero in my output dataset. The data files themselves should be fine and I don't believe that's the issue. Anybody got any ideas what might be causing the extra couple lines?
Thanks,
Mike, do
1009 | /*create variables*/ |
1010 | libname in "/work/mg/AutomationTest"; |
NOTE: Libname IN refers to the same physical library as EX.
NOTE: Libref IN was successfully assigned as follows:
Engine: | V9 | |
Physical Name: /work/mg/AutomationTest |
1011
1012 | %let nummodeled = 3; | |
1013 | %let numg = 4; | |
1014 | %macro addAO; | |
1015 | data in.fact_prelog; | |
1016 | set in.fact_acv; | |
1017 | %do i = 1 %to &nummodeled; | |
1018 | BASEUNITSAO&i = 0; | |
1019 | EQBASEVOLAO&i = 0; | |
1020 | EQVOLAO&i= 0; | |
1021 | UNITSAO&i= 0; | |
1022 | DOLAO&i= 0; | |
1023 | BASEDOLAO&i= 0; | |
1024 | featall_bvolAO&i= 0; | |
1025 | feat_bvolAO&i= 0; | |
1026 | fandd_bvolAO&i= 0; | |
1027 | disp_bvolAO&i= 0; | |
1028 | %do j = 1 %to &numg; | |
1029 | BASEUNITSAO&i = BASEUNITSAO&i + BASEUNITS&j; | |
1030 | EQBASEVOLAO&i = EQBASEVOLAO&i + EQBASEVOL&j; | |
1031 | EQVOLAO&i = EQVOLAO&i + EQVOL&j; | |
1032 | UNITSAO&i = UNITSAO&i + UNITS&j; | |
1033 | DOLAO&i = DOLAO&i + DOL&j; | |
1034 | BASEDOLAO&i = BASEDOLAO&i + BASEDOL&j; | |
1035 | featall_bvolAO&i = featall_bvolAO&i + featall_bvol&j; | |
1036 | feat_bvolAO&i = feat_bvolAO&i + feat_bvol&j; | |
1037 | fandd_bvolAO&i = fandd_bvolAO&i + fandd_bvol&j; | |
1038 | disp_bvolAO&i = disp_bvolAO&i + disp_bvol&j; | |
1039 | %end; | |
^L37 | The SAS System | 17:36 Tuesday, August 21, 2012 |
1040 | BASEUNITSAO&i = BASEUNITSAO&i - BASEUNITS&i; |
1041 | EQBASEVOLAO&i = EQBASEVOLAO&i - EQBASEVOL&i; |
1042 | EQVOLAO&i = EQVOLAO&i - EQVOL&i; |
1043 | UNITSAO&i = UNITSAO&i - UNITS&i; |
1044 | DOLAO&i = DOLAO&i - DOL&i; |
1045 | BASEDOLAO&i = BASEDOLAO&i - BASEDOL&i; |
1046 | featall_bvolAO&i = featall_bvolAO&i - featall_bvol&i; |
1047 | feat_bvolAO&i = feat_bvolAO&i - feat_bvol&i; |
1048 | fandd_bvolAO&i = fandd_bvolAO&i - fandd_bvol&i; |
1049 | disp_bvolAO&i = disp_bvolAO&i - disp_bvol&i; |
1050 | PRICEAO&i = DOLAO&i/EQVOLAO&i; |
1051 | EQREGPRICEAO&i = BASEDOLAO&i/EQBASEVOLAO&i; |
1052 | pct_featallAO&i = featall_bvolAO&i/EQBASEVOLAO&i; |
1053 | pct_featAO&i = feat_bvolAO&i/EQBASEVOLAO&i; |
1054 | pct_fanddAO&i = fandd_bvolAO&i/EQBASEVOLAO&i; |
1055 | pct_dispAO&i = disp_bvolAO&i/EQBASEVOLAO&i; |
1056 | PROMOPRICEAO&i = PRICE AO&i/ EQREGPRICEAO&i; |
1057 | %end; |
1058
1059 | %mend addAO; |
1060
1061 | %addAO; |
NOTE: Line generated by the macro variable "I".
1061 | AO1 |
___ | |
22 |
NOTE: Line generated by the macro variable "I".
1061 | AO2 |
___ | |
22 |
NOTE: Line generated by the macro variable "I".
1061 | AO3 |
___ | |
22 |
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, -, /, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT,
LE, LT, MAX, MIN, NE, NG, NL, OR, [, ^=, {, |, ||, ~=. |
1062 | run; |
NOTE: The SAS System stopped processing this step because of errors.
NOTE: SAS set option OBS=0 and will continue to check statements. This may cause NOTE: No observations in data set.
WARNING: The data set IN.FACT_PRELOG may be incomplete. When this step was stopped there were 0 observations and 143 variables.
WARNING: Data set IN.FACT_PRELOG was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time | 0.03 seconds | |
cpu time | 0.02 seconds |
You appear to have an extra space in the middle of one of statements.
Between the E and A in PRICEAO&i
PROMOPRICEAO&i = PRICE AO&i/ EQREGPRICEAO&i;
This is a great example of where to not use macros. Use an array instead.
Its weird to see the SAS title in the middle of your code like that. Is this from the LOG directly?
yeah I posted the log directly in. I don't know how to use arrays and I'm trying to get this program done ASAP the way I know how. I'll definitely look into it once I get a chance to improving my code beyond the "it works" stage.
You appear to have an extra space in the middle of one of statements.
Between the E and A in PRICEAO&i
PROMOPRICEAO&i = PRICE AO&i/ EQREGPRICEAO&i;
Thanks, that was indeed the problem.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.