9 The SAS System Tuesday 26 January 2021 04:11:00 PM 215 %let etls_resetRestart = 1; 216 10 The SAS System Tuesday 26 January 2021 04:11:00 PM 217 /**************************************************************************** 218 * Job: VDARL_PostgresTest A5LWFIG5.BR0000B5 * 219 * Description: Pushing s3 data into Postgres * 220 * * 221 * Metadata Server: ndgmcdf.co.za * 222 * Port: 8561 * 223 * Location: /Shared Data/UAT/ECC/Test * 224 * * 225 * Server: SASApp A5LWFIG5.AT000002 * 226 * * 227 * Generated on: Tuesday 26 January 2021 4:31:42 PM * 228 * Generated by: unknown * 229 * Version: SAS Data Integration Studio 4.905 * 230 ****************************************************************************/ 231 232 /* Generate the process id for job */ 233 %put Process ID: &SYSJOBID; Process ID: 32303 234 235 /* General macro variables */ 236 %let jobID = %quote(A5LWFIG5.BR0000B5); 237 %let etls_jobName = %nrquote(VDARL_PostgresTest); 238 %let etls_userID = %nrquote(unknown); 239 240 %global applName; 241 data _null_; 242 applName="SAS Data Integration Studio"; 243 call symput('applName',%nrstr(applName)); 244 run; NOTE: PROCEDURE| _DISARM| STOP| _DISARM| 2021-01-26T16:31:43,293+02:00| _DISARM| WorkspaceServer| _DISARM| | _DISARM| | _DISARM| | _DISARM| 10915840| _DISARM| 11| _DISARM| 11| _DISARM| 0| _DISARM| 400| _DISARM| | _DISARM| | _DISARM| | _DISARM| | _DISARM| | _DISARM| | _ENDDISARM NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 245 /* Performance Statistics require ARM_PROC sub-system */ 246 %macro etls_startPerformanceStats; 247 %log4sas(); 248 %log4sas_logger(Perf.ARM, 'level=info'); 249 options armagent=log4sas armsubsys=(ARM_PROC); 250 %global _armexec; 251 %let _armexec = 1; 252 %perfinit(applname="&applName"); 253 %global etls_recnt; 254 %let etls_recnt=-1; 255 %mend; 256 %etls_startPerformanceStats; MPRINT(LOG4SAS): ; MPRINT(ETLS_STARTPERFORMANCESTATS): ; MPRINT(ETLS_STARTPERFORMANCESTATS): ; MPRINT(ETLS_STARTPERFORMANCESTATS): options armagent=log4sas armsubsys=(ARM_PROC); MPRINT(PERFINIT): options notes nosource nosource2 nosymbolgen nomprint nomlogic MPRINT(PERFINIT): NOSYMBOLGEN ; MPRINT(PERFINIT): ; MPRINT(ETLS_STARTPERFORMANCESTATS): ; 11 The SAS System Tuesday 26 January 2021 04:11:00 PM 257 258 %macro etls_setArmagent; 259 %let armagentLength = %length(%sysfunc(getoption(armagent))); 260 %if (&armagentLength eq 0) %then 261 %do; 262 %log4sas(); 263 %log4sas_logger(Perf.ARM, 'level=info'); 264 options armagent=log4sas armsubsys=(ARM_PROC); 265 %end; 266 %mend etls_setArmagent; 267 268 %macro etls_setPerfInit; 269 %if "&_perfinit" eq "0" %then 270 %do; 271 %etls_setArmagent; 272 %global _armexec; 273 %let _armexec = 1; 274 %perfinit(applname="&applName"); 275 %end; 276 %mend etls_setPerfInit; 277 278 /* Setup to capture return codes */ 279 %global job_rc trans_rc sqlrc; 280 %let sysrc=0; 281 %let job_rc = 0; 282 %let trans_rc = 0; 283 %let sqlrc = 0; 284 %let syscc = 0; 285 %global etls_stepStartTime; 286 /* initialize syserr to 0 */ 287 data _null_; run; NOTE: PROCEDURE| _DISARM| STOP| _DISARM| 2021-01-26T16:31:43,297+02:00| _DISARM| WorkspaceServer| _DISARM| SAS| _DISARM| | _DISARM| 11444224| _DISARM| 10915840| _DISARM| 11| _DISARM| 11| _DISARM| 0| _DISARM| 512| _DISARM| 0.000000| _DISARM| 0.000650| _DISARM| 1927290703.296902| _DISARM| 1927290703.297552| _DISARM| 0.000000| _DISARM| | _ENDDISARM NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 288 289 %macro rcSet(error); 290 %if (&error gt &trans_rc) %then 291 %let trans_rc = &error; 292 %if (&error gt &job_rc) %then 293 %let job_rc = &error; 294 %mend rcSet; 295 296 %macro rcSetDS(error); 297 if &error gt input(symget('trans_rc'),12.) then 298 call symput('trans_rc',trim(left(put(&error,12.)))); 299 if &error gt input(symget('job_rc'),12.) then 300 call symput('job_rc',trim(left(put(&error,12.)))); 301 %mend rcSetDS; 302 303 /* Setup for capturing job status */ 304 %let etls_startTime = %sysfunc(datetime(),datetime.); 305 %let etls_recordsBefore = 0; 12 The SAS System Tuesday 26 January 2021 04:11:00 PM 306 %let etls_recordsAfter = 0; 307 %let etls_lib = 0; 308 %let etls_table = 0; 309 310 %global etls_debug; 311 %macro etls_setDebug; 312 %if %str(&etls_debug) ne 0 %then 313 OPTIONS MPRINT%str(;); 314 %mend; 315 %etls_setDebug; MPRINT(ETLS_SETDEBUG): OPTIONS MPRINT; 316 317 13 The SAS System Tuesday 26 January 2021 04:11:00 PM 318 /*==========================================================================* 319 * Step: Download File From Amazon S3 A5LWFIG5.$0001742 * 320 * Transform: Download File From Amazon S3 * 321 * Description: Downloads a file from Amazon S3. * 322 *==========================================================================*/ 323 324 %let transformID = %quote(A5LWFIG5.$0001742); 325 %let trans_rc = 0; 326 %let etls_stepStartTime = %sysfunc(datetime(), datetime20.); 327 328 /* Runtime statistics macros */ 329 %etls_setPerfInit; 330 %perfstrt(txnname=%BQUOTE(_DISARM|&transformID|&syshostname|GeneratedTransform), metrNam6=_DISROWCNT, metrDef6=Count32) 330 ! ; MPRINT(PERFSTRT): options notes nosource nosource2 nosymbolgen nomprint nomlogic MPRINT(PERFSTRT): NOSYMBOLGEN ; MPRINT(PERFSTRT): ; MPRINT(PERFSTRT): ; 331 332 %let _INPUT_count = 0; 333 %let _OUTPUT_count = 0; 334 335 %let etls_useConfig = %nrquote(No); 336 %let etls_s3Config = ; 337 %let etls_awsRegion = %nrquote(af-south-1); 338 %let etls_awsAccessKeyId = %nrquote(xxxxxsdxsd" secret="ddbfbhjvjsdjnsdn" region=af-south-1 get ); 339 %let etls_awsSecretKey = %nrquoteddbfbhjvjsdjnsdn); 340 %let etls_enableSSL = %nrquote(Yes); 341 %let etls_s3inputFile = %nrquote(/inputfile); 342 %let etls_outputFile = %nrquote(output); 343 %let etls_outputFile_server = %nrquote(SASApp - Logical Workspace Server); 344 %let etls_outputFileReplace = %nrquote(Yes); 345 346 %global etls_s3inputFile; 347 %let etls_fileExist=FALSE; 348 %let quotelenmax_option=%sysfunc(getoption(quotelenmax)); 349 options noquotelenmax; 350 351 %macro checkTargetFileExist(); 352 353 %if %upcase(&etls_outputFileReplace.) eq NO %then %do; 354 355 data _null_; 356 if fileexist("&etls_outputFile.") then 357 call symputx('etls_fileExist','Yes'); 358 else 359 call symputx('etls_fileExist','No'); 360 run; 361 362 %end; 363 364 %mend; 365 %checkTargetFileExist(); 366 367 368 %macro etls_procS3(); 369 370 %if (%upcase(&etls_outputFileReplace.) eq YES) or 14 The SAS System Tuesday 26 January 2021 04:11:00 PM 371 (%upcase(&etls_outputFileReplace.) eq NO and %upcase(&etls_fileExist.) eq NO) %then %do; 372 373 %if %upcase(&etls_useConfig.) eq YES %then %do; 374 proc s3 config="&etls_s3Config."; 375 get "&etls_s3inputFile." "&etls_outputFile."; 376 run; 377 %end; 378 %else %do; 379 %if %upcase(&etls_enableSSL.) eq YES %then %do; 380 %let ssl=; 381 %end; 382 %else %do; 383 %let ssl = NOSSL; 384 %end; 385 386 proc s3 keyid="&etls_awsAccessKeyId." 387 secret="&etls_awsSecretKey." 388 &ssl. 389 region=&etls_awsRegion.; 390 get "&etls_s3inputFile." "&etls_outputFile."; 391 run; 392 %end; 393 %end; 394 %else %do; 395 %if (%upcase(&etls_outputFileReplace.) eq NO and %upcase(&etls_fileExist.) eq YES) %then %do; 396 %put WARNING: 'Replace output file' option set to "&etls_outputFileReplace." and output file "&etls_outputFile." 396 ! exists.; 397 %put WARNING- S3 File: "&etls_s3inputFile.". Local file: "&etls_outputFile."; 398 %put WARNING- The output file "&etls_outputFile." will not be replaced.; 399 %end; 400 %end; 401 402 %mend; 403 %etls_procS3(); NOTE: Line generated by the macro variable "ETLS_AWSREGION". 403 af-south-1 __ 22 __ 76 MPRINT(ETLS_PROCS3): proc s3 keyid="xxxxxsdxsd" secret="ddbfbhjvjsdjnsdn" region=af-south-1 get "inputfile" "outputfile"; MPRINT(ETLS_PROCS3): run; ERROR 22-322: Syntax error, expecting one of the following: a quoted string, AFCAPETOWN, APHONGKONG, APINDIA, APOSAKA, APSEOUL, APSINGAPORE, APSYDNEY, APTOKYO, CACENTRAL, CNBEIJING, CNNINGXIA, EUFRANKFURT, EUIRELAND, EULONDON, EUMILAN, EUPARIS, EUSTOCKHOLM, FIPS, MEBAHRAIN, SA, USEAST, USEASTOH, USGOV, USSTD, USWEST, USWESTCA. ERROR 76-322: Syntax error, statement will be ignored. NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE| _DISARM| STOP| _DISARM| 2021-01-26T16:31:43,726+02:00| _DISARM| WorkspaceServer| _DISARM| SAS| _DISARM| | _DISARM| 11444224| _DISARM| 10915840| _DISARM| 11| _DISARM| 11| _DISARM| 0| _DISARM| 536| _DISARM| 0.000000| _DISARM| 0.000366| _DISARM| 1927290703.725750| _DISARM| 1927290703.726116| _DISARM| 0.000000| _DISARM| | _ENDDISARM NOTE: PROCEDURE S3 used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 15 The SAS System Tuesday 26 January 2021 04:11:00 PM 404 405 options "elenmax_option; 406 407 408 %rcSet(&syserr); 409 %rcSet(&sysrc); 410 %rcSet(&sqlrc); 411 412 %perfstop(metrVal6=%sysfunc(max(&etls_recnt,-1))); MPRINT(PERFSTOP): options notes nosource nosource2 nosymbolgen nomprint nomlogic NOTE: _DISARM|A5LWFIG5.$0001742|jdgsassapprd1|GeneratedTransform| _DISARM| STOP| _DISARM| 2021-01-26T16:31:43,727+02:00| _DISARM| SAS_Data_Integration_Studio| _DISARM| SAS| _DISARM| -1| _DISARM| 11444224| _DISARM| 10915840| _DISARM| 11| _DISARM| 11| _DISARM| 24| _DISARM| 560| _DISARM| 0.000000| _DISARM| 0.003465| _DISARM| 1927290703.723747| _DISARM| 1927290703.727212| _DISARM| 0.000000| _DISARM| | _ENDDISARM MPRINT(PERFSTOP): NOSYMBOLGEN ; MPRINT(PERFSTOP): ; MPRINT(PERFSTOP): ; 413 %let etls_recnt=-1; 414 415 416 417 /** Step end Download File From Amazon S3 **/ 418 419 16 The SAS System Tuesday 26 January 2021 04:11:00 PM 420 %let etls_endTime = %sysfunc(datetime(),datetime.); 421 422 /* Turn off performance statistics collection */ 423 data _null_; 424 if "&_perfinit" eq "1" then 425 call execute('%perfend;'); 426 427 run; MPRINT(PERFEND): options notes nosource nosource2 nosymbolgen nomprint nomlogic ; MPRINT(PERFEND): ; MPRINT(PERFEND): ; MPRINT(PERFEND): options NOTES SOURCE NOSOURCE2 MPRINT NOMLOGIC NOSYMBOLGEN ; MPRINT(PERFEND): ; MPRINT(PERFEND): ; NOTE: PROCEDURE| _DISARM| STOP| _DISARM| 2021-01-26T16:31:44,233+02:00| _DISARM| WorkspaceServer| _DISARM| SAS| _DISARM| | _DISARM| 11444224| _DISARM| 10915840| _DISARM| 11| _DISARM| 11| _DISARM| 0| _DISARM| 560| _DISARM| 0.000000| _DISARM| 0.001203| _DISARM| | _DISARM| 1927290704.233731| _DISARM| 0.000000| _DISARM| | _ENDDISARM NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds NOTE: CALL EXECUTE generated line. 1 + options notes nosource nosource2 nosymbolgen nomprint nomlogic ;;; options NOTES SOURCE NOSOURCE2 MPRINT NOMLOGIC NOSYMBOLGEN ;;;; 428
Hi everyone,
I'm trying to download a file from an s3 bucket in amazon using DI Studio. I've created a job to download the file from the bucket, however I get errors when I run the job; the error states the following : "ERROR 22-322: Syntax error, expecting one of the following: a quoted string, AFCAPETOWN, APHONGKONG, APINDIA, APOSAKA, APSEOUL, APSINGAPORE, APSYDNEY, APTOKYO, CACENTRAL, CNBEIJING, CNNINGXIA, EUFRANKFURT, EUIRELAND, EULONDON, EUMILAN, EUPARIS, EUSTOCKHOLM, FIPS, MEBAHRAIN, SA, USEAST, USEASTOH, USGOV, USSTD, USWEST, USWESTCA". I'm using the awsregion "af-south-1" and that's where the job fails.
Thank you.
Seem like there are at least two errors in these %LET statements:
338 %let etls_awsAccessKeyId = %nrquote(xxxxxsdxsd" secret="ddbfbhjvjsdjnsdn" region=af-south-1 get ); 339 %let etls_awsSecretKey = %nrquoteddbfbhjvjsdjnsdn);
The first has unmatched quotation marks. The second has mismatched parentheses. Since these are used in the same PROC call as etls_awsRegion, you should fix those errors first.
*****************************************************************/ /* Generate the process id for job */ %put Process ID: &SYSJOBID; /* General macro variables */ %let jobID = %quote(A5LWFIG5.BR0000B5); %let etls_jobName = %nrquote(VDARL_PostgresTest); %let etls_userID = %nrquote(unknown); %global applName; data _null_; applName="SAS Data Integration Studio"; call symput('applName',%nrstr(applName)); run; /* Performance Statistics require ARM_PROC sub-system */ %macro etls_startPerformanceStats; %log4sas(); %log4sas_logger(Perf.ARM, 'level=info'); options armagent=log4sas armsubsys=(ARM_PROC); %global _armexec; %let _armexec = 1; %perfinit(applname="&applName"); %global etls_recnt; %let etls_recnt=-1; %mend; %etls_startPerformanceStats; %macro etls_setArmagent; %let armagentLength = %length(%sysfunc(getoption(armagent))); %if (&armagentLength eq 0) %then %do; %log4sas(); %log4sas_logger(Perf.ARM, 'level=info'); options armagent=log4sas armsubsys=(ARM_PROC); %end; %mend etls_setArmagent; %macro etls_setPerfInit; %if "&_perfinit" eq "0" %then %do; %etls_setArmagent; %global _armexec; %let _armexec = 1; %perfinit(applname="&applName"); %end; %mend etls_setPerfInit; /* Setup to capture return codes */ %global job_rc trans_rc sqlrc; %let sysrc=0; %let job_rc = 0; %let trans_rc = 0; %let sqlrc = 0; %let syscc = 0; %global etls_stepStartTime; /* initialize syserr to 0 */ data _null_; run; %macro rcSet(error); %if (&error gt &trans_rc) %then %let trans_rc = &error; %if (&error gt &job_rc) %then %let job_rc = &error; %mend rcSet; %macro rcSetDS(error); if &error gt input(symget('trans_rc'),12.) then call symput('trans_rc',trim(left(put(&error,12.)))); if &error gt input(symget('job_rc'),12.) then call symput('job_rc',trim(left(put(&error,12.)))); %mend rcSetDS; /* Setup for capturing job status */ %let etls_startTime = %sysfunc(datetime(),datetime.); %let etls_recordsBefore = 0; %let etls_recordsAfter = 0; %let etls_lib = 0; %let etls_table = 0; %global etls_debug; %macro etls_setDebug; %if %str(&etls_debug) ne 0 %then OPTIONS MPRINT%str(;); %mend; %etls_setDebug; /*==========================================================================* * Step: Download File From Amazon S3 A5LWFIG5.BU0000KU * * Transform: Download File From Amazon S3 * * Description: Downloads a file from Amazon S3. * *==========================================================================*/ %let transformID = %quote(A5LWFIG5.BU0000KU); %let trans_rc = 0; %let etls_stepStartTime = %sysfunc(datetime(), datetime20.); /* Runtime statistics macros */ %etls_setPerfInit; %perfstrt(txnname=%BQUOTE(_DISARM|&transformID|&syshostname|GeneratedTransform), metrNam6=_DISROWCNT, metrDef6=Count32) ; %let _INPUT_count = 0; %let _OUTPUT_count = 0; %let etls_useConfig = %nrquote(No); %let etls_s3Config = ; %let etls_awsRegion = %nrquote(af-south-1); %let etls_awsAccessKeyId = %nrquote(accesskeyid); %let etls_awsSecretKey = %nrquote(secretkey); %let etls_enableSSL = %nrquote(Yes); %let etls_s3inputFile = %nrquote(/inputfile); %let etls_outputFile = %nrquote(/outputfile); %let etls_outputFile_server = %nrquote(SASApp - Logical Workspace Server); %let etls_outputFileReplace = %nrquote(Yes); %global etls_s3inputFile; %let etls_fileExist=FALSE; %let quotelenmax_option=%sysfunc(getoption(quotelenmax)); options noquotelenmax; %macro checkTargetFileExist(); %if %upcase(&etls_outputFileReplace.) eq NO %then %do; data _null_; if fileexist("&etls_outputFile.") then call symputx('etls_fileExist','Yes'); else call symputx('etls_fileExist','No'); run; %end; %mend; %checkTargetFileExist(); %macro etls_procS3(); %if (%upcase(&etls_outputFileReplace.) eq YES) or (%upcase(&etls_outputFileReplace.) eq NO and %upcase(&etls_fileExist.) eq NO) %then %do; %if %upcase(&etls_useConfig.) eq YES %then %do; proc s3 config="&etls_s3Config."; get "&etls_s3inputFile." "&etls_outputFile."; run; %end; %else %do; %if %upcase(&etls_enableSSL.) eq YES %then %do; %let ssl=; %end; %else %do; %let ssl = NOSSL; %end; proc s3 keyid="&etls_awsAccessKeyId." secret="&etls_awsSecretKey." &ssl. region=&etls_awsRegion.; get "&etls_s3inputFile." "&etls_outputFile."; run; %end; %end; %else %do; %if (%upcase(&etls_outputFileReplace.) eq NO and %upcase(&etls_fileExist.) eq YES) %then %do; %put WARNING: 'Replace output file' option set to "&etls_outputFileReplace." and output file "&etls_outputFile." exists.; %put WARNING- S3 File: "&etls_s3inputFile.". Local file: "&etls_outputFile."; %put WARNING- The output file "&etls_outputFile." will not be replaced.; %end; %end; %mend; %etls_procS3(); options "elenmax_option; %rcSet(&syserr); %rcSet(&sysrc); %rcSet(&sqlrc); %perfstop(metrVal6=%sysfunc(max(&etls_recnt,-1))); %let etls_recnt=-1; /** Step end Download File From Amazon S3 **/ %let etls_endTime = %sysfunc(datetime(),datetime.); /* Turn off performance statistics collection */ data _null_; if "&_perfinit" eq "1" then call execute('%perfend;'); run;
@Rick_SAS i've also added the code that the sas job runs for a clearer picture as well.
Good luck. I'm sure someone will be able to help you debug your macro.
Hi @Gweeks,
I have never used PROC S3, but my understanding of the documentation is that the REGION= option should be specified as
region=afcapetown
instead of region=af-south-1. This is also consistent with the error message.
Of course, the errors in the two %LET statements indicated by Rick_SAS need to be corrected as well.
Hi @FreelanceReinh ,
I've done the changes recommended by @Rick_SAS and also changed the region to "afcapetown". And it's still giving me the same error message as before.
NOTE: Line generated by the macro variable "ETLS_AWSREGION". 617 "afcapetown" _ 22 _ 200 MPRINT(ETLS_PROCS3): proc s3 keyid="keyid" secret="secret" region="afcapetown"; MPRINT(ETLS_PROCS3): get "/input" "/output"; MPRINT(ETLS_PROCS3): run; ERROR 22-322: Syntax error, expecting one of the following: a quoted string, AFCAPETOWN, APHONGKONG, APINDIA, APOSAKA, APSEOUL, APSINGAPORE, APSYDNEY, APTOKYO, CACENTRAL, CNBEIJING, CNNINGXIA, EUFRANKFURT, EUIRELAND, EULONDON, EUMILAN, EUPARIS, EUSTOCKHOLM, FIPS, MEBAHRAIN, SA, USEAST, USEASTOH, USGOV, USSTD, USWEST, USWESTCA. ERROR 200-322: The symbol is not recognized and will be ignored.
Did you (wrongly) add quotation marks around afcapetown?
So without the added quotation marks, it isn't able to identify the "object" or the directory we're trying to read the data from
, that's the error it gives. So I had to add in the quotation marks.
The documentation does not mention quotes around the "PROC S3 Region Values," that's why I think they should be omitted. It says, however,
"You might need to activate a region for your account if it does not appear in your list of regions. See your AWS documentation for more information."
Maybe this is the reason why afcapetown is not (yet) available to your system. Another reason might be the SAS release: In my offline help file (I'm using SAS 9.4M5) there's no African region listed at all, i.e., afcapetown seems to be a recent addition in 9.4M6 or later.
Sorry, this is pretty much all I can contribute to this thread, having never used PROC S3 or the AWS S3 environment.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.