BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dennis_oz
Quartz | Level 8

Hi All,

I am getting the below error when write to a SAS Dataset in a macro ..  is the " ; "  causing the error ? In the SAS code that I have pasted below , i tried putting a %str around the dataset but no luck.

Can any one please help

 

Log ERROR:

*-----------------------------------*

MPRINT(IMPORT_STRATEGICFILE): ;
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT, IN,
LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.
SYMBOLGEN: Macro variable OUTPUT_FILE resolves to STRATEGIC_EXPORT
MPRINT(IMPORT_STRATEGICFILE): data MY_LIB.STRATEGIC_EXPORT;
MPRINT(IMPORT_STRATEGICFILE): Format Response_File_Load_Date date9.;
SYMBOLGEN: Macro variable OUTPUT_FILE resolves to STRATEGIC_EXPORT
MPRINT(IMPORT_STRATEGICFILE): set work.STRATEGIC_EXPORT;
SYMBOLGEN: Macro variable FILE_UPLOAD_DATE resolves to 21MAY2020
MPRINT(IMPORT_STRATEGICFILE): Response_File_Load_Date=21MAY2020;
MPRINT(IMPORT_STRATEGICFILE): run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: MVA_DSIO.OPEN_CLOSE| _DISARM| STOP| _DISARM| 2020-05-26T22:48:27,041+10:00| _DISARM| WorkspaceServer| _DISARM| SAS|
_DISARM| | _DISARM| | _DISARM| 29663232| _DISARM| 11| _DISARM| 11| _DISARM| 4065| _DISARM| 12053868| _DISARM| 0.015625|
_DISARM| 0.015000| _DISARM| 1906116507.027000| _DISARM| 1906116507.042000| _DISARM| 0.015625| _DISARM| | _ENDDISARM
WARNING: The data set MY_LIB.STRATEGIC_EXPORT may be incomplete. When this step was stopped there were 0 observations and 85

 

 

SAS Code:

 

data MY_LIB.%str(&output_file.);
Format Response_File_Load_Date date9.;
set work.&output_file.;
Response_File_Load_Date=&file_upload_date.;
run;

 


variables.

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

This line in your original code makes it clear that you were hoping to get a SAS date value into your new variable:

 

Format Response_File_Load_Date date9.;

 

Under those conditions, and given that &FILE_UPLOAD_DATE resolves to a value in the DATE9 format, your assignment statement should read:

 

Response_File_Load_Date="&file_upload_date."d;

View solution in original post

8 REPLIES 8
PaigeMiller
Diamond | Level 26

Please follow these instructions to help us better interpret the LOG you are showing.

 

Paste the log as text into the window that appears when you click on the </> icon.

--
Paige Miller
PaigeMiller
Diamond | Level 26
MPRINT(IMPORT_STRATEGICFILE): Response_File_Load_Date=21MAY2020;

When you create macros, they produce text that must be VALID legal working SAS code. Your macro produces the above line of code. The above line is not a valid line in a DATA step, it does not work and causes an error. Can you figure out why the above line of code is not valid in a DATA step?

--
Paige Miller
dennis_oz
Quartz | Level 8
is it because it's a data and should be '21MAY2020'd##- Please type your
reply above this line. No attachments. -##
PaigeMiller
Diamond | Level 26

So can you now fix the DATA step code to properly make use of macro variable &file_upload_date ??

--
Paige Miller
Tom
Super User Tom
Super User

You should NOT add macro quoting around the name of a dataset. The name of dataset cannot contain anything that would require macro quoting.  Plus the presence of the macro quoting might confuse the parser.

 

This line of code being generated is not valid SAS syntax.

MPRINT(IMPORT_STRATEGICFILE): Response_File_Load_Date=21MAY2020;

What is it that you want on the right side of that assignment statement?  A string? A variable name? A date?

Response_File_Load_Date="21MAY2020";
Response_File_Load_Date="21MAY2020"n;
Response_File_Load_Date="21MAY2020"d;

 

Astounding
PROC Star

This line in your original code makes it clear that you were hoping to get a SAS date value into your new variable:

 

Format Response_File_Load_Date date9.;

 

Under those conditions, and given that &FILE_UPLOAD_DATE resolves to a value in the DATE9 format, your assignment statement should read:

 

Response_File_Load_Date="&file_upload_date."d;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 954 views
  • 6 likes
  • 5 in conversation