BookmarkSubscribeRSS Feed
Trunghuynh
Calcite | Level 5

Hi all, seeking your support to look at below error in red, i have spent hours but cannot figure out

 

1 The SAS System 15:25 Monday, August 9, 2021

1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Dailly_report_Error_Apply_From_Mar2020_testing 1.sas';
4 %LET _CLIENTPROCESSFLOWNAME='Standalone Not In Project';
5 %LET _CLIENTPROJECTPATH='';
6 %LET _CLIENTPROJECTPATHHOST='';
7 %LET _CLIENTPROJECTNAME='';
8 %LET _SASPROGRAMFILE='/proj/sas/sasdata/basesas/nonrisk/VOCD/Trung/Source
8 ! code/Dailly_report_Error_Apply_From_Mar2020_testing 1.sas';
9 %LET _SASPROGRAMFILEHOST='pecda15l.unix.anz';
10
11 ODS _ALL_ CLOSE;
12 OPTIONS DEV=SVG;
13 GOPTIONS XPIXELS=0 YPIXELS=0;
14 %macro HTML5AccessibleGraphSupported;
15 %if %_SAS_VERCOMP_FV(9,4,4, 0,0,0) >= 0 %then ACCESSIBLE_GRAPH;
16 %mend;
17 FILENAME EGHTML TEMP;
18 ODS HTML5(ID=EGHTML) FILE=EGHTML
19 OPTIONS(BITMAP_MODE='INLINE')
20 %HTML5AccessibleGraphSupported
21 ENCODING='utf-8'
22 STYLE=HTMLBlue
23 NOGTITLE
24 NOGFOOTNOTE
25 GPATH=&sasworklocation
26 ;
NOTE: Writing HTML5(EGHTML) Body file: EGHTML
27
28 /*-------------------------------------------MACRO HERE-------------------------------------------*/
29 %macro io(fn, datafile, data, type);
30 %if &fn=import %then %do;
31 proc import datafile="&datafile"
32 out=&data
33 dbms=&type replace;
34 run;
35 %end;
36 %else %if &fn=export %then %do;
37 proc export data=&data
38 outfile="&datafile"
39 dbms=&type
40 replace;
41 run;
42 %end;
43 %mend;
44 /*----------------------------------------END OF MACRO HERE----------------------------------------*/
45 %LET Date_Last_Working = 3007;
46
47 %let depo_last = DEPO3007;
48 %let ah_last = CBO3007;
49
50 %let depo_last2 = DEPO2907;
51 %let ah_last2 = CBO2907;
52
53 %let N = 10;
54
55 %let path = /proj/sas/sasdata/basesas/nonrisk/VOCD/Trung;
56
2 The SAS System 15:25 Monday, August 9, 2021

57 %io(import,&path/RAW DATA/Holiday, Holiday, xlsx);

NOTE: One or more variables were converted because the data type is not supported by the V9 engine. For more details, run with
options MSGLEVEL=I.
NOTE: The import data set has 18 observations and 4 variables.
NOTE: WORK.HOLIDAY data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

58
59 data mon_fri;
60 do date = intnx('year',today(),-1,'B') to intnx('year',today(),0,'E');
61 if weekday(date) in (2:6) then output;
62 end;
63 format date date9.;
64 run;

NOTE: The data set WORK.MON_FRI has 523 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

65
66 data Holiday (keep = Date);
67 set Holiday;
68 run;

NOTE: There were 18 observations read from the data set WORK.HOLIDAY.
NOTE: The data set WORK.HOLIDAY has 18 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds

69
70 data myworksday(RENAME=(date=Begin));
71 merge mon_fri (in=weekday)
72 Holiday (in=holiday);
73 by date;
74 if weekday and not holiday then output;
75 run;

NOTE: There were 523 observations read from the data set WORK.MON_FRI.
NOTE: There were 18 observations read from the data set WORK.HOLIDAY.
NOTE: The data set WORK.MYWORKSDAY has 510 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

76
77 PROC SQL;
78 CREATE TABLE Date_Last_Working AS
79 SELECT Max(Begin) AS Date_Last_Working
80 FROM myworksday
3 The SAS System 15:25 Monday, August 9, 2021

81 WHERE Begin < today() - &N;
NOTE: Table WORK.DATE_LAST_WORKING created, with 1 rows and 1 columns.

82 QUIT;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds

83
84 DATA PATH;
85 SET Date_Last_Working;
86 iMONTH= PUT(today() - &N, monname3.);
87 iYEAR= YEAR(today() - &N);
88 iPATH = CAT(iMONTH,"", iYEAR);
89 RUN;

NOTE: There were 1 observations read from the data set WORK.DATE_LAST_WORKING.
NOTE: The data set WORK.PATH has 1 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.02 seconds

90
91 PROC SQL NOPRINT;
92 SELECT iPATH INTO:iPATH
93 FROM PATH;
94 %PUT &iPATH;
Jul 2021
95 RUN;
NOTE: PROC SQL statements are executed immediately; The RUN statement has no effect.
96
97
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

98 PROC SQL;
99 CREATE TABLE Date_Last_Working2 AS
100 SELECT Max(Begin) AS Date_Last_Working2
101 FROM myworksday
102 WHERE Begin < (SELECT Max(Date_Last_Working) FROM Date_Last_Working);
NOTE: Table WORK.DATE_LAST_WORKING2 created, with 1 rows and 1 columns.

103 QUIT;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.05 seconds
cpu time 0.00 seconds

104
105 DATA Date_Last_Working(KEEP=Date_LW1);
106 SET Date_Last_Working;
107 if DAY(Date_Last_Working) < 10 then day_1=cat("0",DAY(Date_Last_Working));
108 else day_1= cat("",DAY(Date_Last_Working));
109 if MONTH(Date_Last_Working) < 10 then month_1=cat("0",MONTH(Date_Last_Working));
4 The SAS System 15:25 Monday, August 9, 2021

110 else month_1= cat("",MONTH(Date_Last_Working));
111 Date_LW1=CATT(DAY_1, MONTH_1);
112 RUN;

NOTE: There were 1 observations read from the data set WORK.DATE_LAST_WORKING.
NOTE: The data set WORK.DATE_LAST_WORKING has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.02 seconds

113
114
115
116 DATA Date_Last_Working;
117 SET Date_Last_Working;
118 DEPO1=COMPRESS(CATT("DEPO",Date_LW1));
119 AH1=COMPRESS(CATT("CBO",Date_LW1));
120 RUN;

NOTE: There were 1 observations read from the data set WORK.DATE_LAST_WORKING.
NOTE: The data set WORK.DATE_LAST_WORKING has 1 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.05 seconds
cpu time 0.00 seconds

121
122
123 DATA Date_Last_Working2(KEEP=Date_LW2);
124 SET Date_Last_Working2;
125 if DAY(Date_Last_Working2) < 10 then day_2=cat("0",DAY(Date_Last_Working2));
126 else day_2= cat("",DAY(Date_Last_Working2));
127 if MONTH(Date_Last_Working2) < 10 then month_2=cat("0",MONTH(Date_Last_Working2));
128 else month_2= cat("",MONTH(Date_Last_Working2));
129 Date_LW2=CATT(DAY_2, MONTH_2);
130 RUN;

NOTE: There were 1 observations read from the data set WORK.DATE_LAST_WORKING2.
NOTE: The data set WORK.DATE_LAST_WORKING2 has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.05 seconds
cpu time 0.00 seconds

131
132 DATA Date_Last_Working2;
133 SET Date_Last_Working2;
134 DEPO2=COMPRESS(CATT("DEPO",Date_LW2));
135 AH2=COMPRESS(CATT("CBO",Date_LW2));
136 RUN;

NOTE: There were 1 observations read from the data set WORK.DATE_LAST_WORKING2.
NOTE: The data set WORK.DATE_LAST_WORKING2 has 1 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.05 seconds
cpu time 0.01 seconds

5 The SAS System 15:25 Monday, August 9, 2021


137
138 PROC SQL NOPRINT;
139 SELECT DEPO1 INTO:depo_last
140 FROM Date_Last_Working;
141 %PUT &depo_last;
DEPO2907
142 RUN;
NOTE: PROC SQL statements are executed immediately; The RUN statement has no effect.
143
144
NOTE: PROCEDURE SQL used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

145 PROC SQL NOPRINT;
146 SELECT AH1 INTO: ah_last
147 FROM Date_Last_Working;
148 %PUT &ah_last;
CBO2907
149 RUN;
NOTE: PROC SQL statements are executed immediately; The RUN statement has no effect.
150
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

151 PROC SQL NOPRINT;
152 SELECT DEPO2 INTO:depo_last2
153 FROM Date_Last_Working2;
154 %PUT &depo_last2;
DEPO2807
155 RUN;
NOTE: PROC SQL statements are executed immediately; The RUN statement has no effect.
156
NOTE: PROCEDURE SQL used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

157 PROC SQL NOPRINT;
158 SELECT AH2 INTO: ah_last2
159 FROM Date_Last_Working2;
160 %PUT &ah_last2;
CBO2807
161 RUN;
NOTE: PROC SQL statements are executed immediately; The RUN statement has no effect.
162
163 /* ---------------- PROCESS ----------------*/
164
165 %io(import,&path/RAW DATA/DEPO3007.DBF, &depo_last, DBF);
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

6 The SAS System 15:25 Monday, August 9, 2021


NOTE: Imported 22 columns and 3349 rows of data from the dBase table file.
NOTE: WORK.DEPO2907 data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.03 seconds
cpu time 0.02 seconds

166 %io(import,&path/RAW DATA/DEPO2907.DBF, &depo_last2, DBF);

NOTE: Imported 22 columns and 3350 rows of data from the dBase table file.
NOTE: WORK.DEPO2807 data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.03 seconds
cpu time 0.02 seconds

167 %io(import,&path/RAW DATA/CBO3007.DBF, &ah_last, DBF);

NOTE: Imported 62 columns and 41571 rows of data from the dBase table file.
NOTE: WORK.CBO2907 data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.21 seconds
cpu time 0.17 seconds

168 %io(import,&path/RAW DATA/CBO2907.DBF, &ah_last2, DBF);

NOTE: Imported 62 columns and 41599 rows of data from the dBase table file.
NOTE: WORK.CBO2807 data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.22 seconds
cpu time 0.18 seconds

169
170 data &depo_last;
171 set &depo_last;
172 AccountNo = compress(tranwrd(AccountNo, "-",""));
173 run;

NOTE: There were 3349 observations read from the data set WORK.DEPO2907.
NOTE: The data set WORK.DEPO2907 has 3349 observations and 22 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds

174
175 data &depo_last2;
176 set &depo_last2;
177 AccountNo = compress(tranwrd(AccountNo, "-",""));
178 run;

NOTE: There were 3350 observations read from the data set WORK.DEPO2807.
NOTE: The data set WORK.DEPO2807 has 3350 observations and 22 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
7 The SAS System 15:25 Monday, August 9, 2021

cpu time 0.00 seconds

179
180 data &ah_last (drop=old);
181 set &ah_last (rename=(ACCT_NO=oldACCT CUST_NO=oldCUST SEGMENT_ID=oldSEGMENT_ID ACCT_TYPE=oldACCT_TYPE));
182 ACCT_NO=input(oldACCT,16.0);
183 CUST_NO=input(oldCUST,16.0);
184 SEGMENT_ID=input(oldSEGMENT_ID,16.0);
185 ACCT_TYPE=input(oldACCT_TYPE,16.0);
186 run;

WARNING: The variable old in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 41571 observations read from the data set WORK.CBO2907.
NOTE: The data set WORK.CBO2907 has 41571 observations and 66 variables.
NOTE: DATA statement used (Total process time):
real time 0.14 seconds
cpu time 0.07 seconds

187
188 data &ah_last2 (drop=old);
189 set &ah_last2 (rename=(ACCT_NO=oldACCT CUST_NO=oldCUST SEGMENT_ID=oldSegmentID ACCT_TYPE=oldACCT_TYPE));
190 ACCT_NO=input(oldACCT,16.0);
191 CUST_NO=input(oldCUST,16.0);
192 SEGMENT_ID=input(oldSegmentID,16.0);
193 ACCT_TYPE=input(oldACCT_TYPE,16.0);
194 run;

WARNING: The variable old in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 41599 observations read from the data set WORK.CBO2807.
NOTE: The data set WORK.CBO2807 has 41599 observations and 66 variables.
NOTE: DATA statement used (Total process time):
real time 0.11 seconds
cpu time 0.07 seconds

195
196 data &depo_last (drop=old);
197 set &depo_last (rename=(AccountNo=oldACCT SegmentCo=oldSegmentCo Balance=oldBalance));
198 AccountNo=input(oldACCT,16.0);
199 Balance=input(oldBalance,16.0);
200 SegmentCo=input(oldSegmentCo,16.0);
201 run;

NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
199:19
WARNING: The variable old in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 3349 observations read from the data set WORK.DEPO2907.
NOTE: The data set WORK.DEPO2907 has 3349 observations and 25 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

202
203
204 data &depo_last2 (drop=old);
8 The SAS System 15:25 Monday, August 9, 2021

205 set &depo_last2 (rename=(AccountNo=oldACCT SegmentCo=oldSegmentCo Balance=oldBalance));
206 AccountNo=input(oldACCT,16.0);
207 Balance=input(oldBalance,16.0);
208 SegmentCo=input(oldSegmentCo,16.0);
209 run;

NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
207:19
WARNING: The variable old in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 3350 observations read from the data set WORK.DEPO2807.
NOTE: The data set WORK.DEPO2807 has 3350 observations and 25 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

210
211 proc sql;
212 create table lastworking2 as
213 select * from &depo_last, &ah_last.cust_no as CIF, &ah_last.name1, &ah_last.name2,&ah_last.add1, &ah_last.add2,
__
22
76
213 ! &ah_last.add3, &ah_last.add4, &ah_last.telex_no, &ah_last.acct_type, &ah_last.int_rate, &ah_last.DEAL_COM_D,
213 ! &ah_last.DEAL_MAT_D from &depo_last2
ERROR 22-322: Syntax error, expecting one of the following: ;, ',', ANSIMISS, CROSS, EXCEPT, FULL, GROUP, HAVING, INNER, INTERSECT,
JOIN, LEFT, NATURAL, NOMISS, ORDER, OUTER, RIGHT, UNION, WHERE.

ERROR 76-322: Syntax error, statement will be ignored.

 

Thanks

2 REPLIES 2
ballardw
Super User

Please in the future when posting LOG text, open a text box on the forum with the </> that appears above the window and paste the text there. The message windows reformat text moving the position of the diagnostic characters posted. The underscore and 22 should appear under the character where SAS determines the error to be.

 

In this case I think this was originally

select * from &depo_last, &ah_last.cust_no as CIF, &ah_last.name1, &ah_last.name2,&ah_l
_

&depo_last is apparently a data set and you cannot have a list of variables, which the &ah_last.cust_no and such appear to be.

You would have to have all the variables on the select. As soon as you have From that ends the select. So SAS expects another a join instruction or end of the select.

 

So you need to go back to the drawing board, or at least the code that worked without any macro variables and see what change you actually need to make to that Proc SQL call.

Trunghuynh
Calcite | Level 5

Hi Ballardw, thanks for your response. Actually the code was running fine on SAS 9.3. I am currently running this code on SAS 9.4 and facing this kind of problem. I will give it a go with your advice and see how it goes. Thanks buddy!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 491 views
  • 1 like
  • 2 in conversation