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.
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;
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.
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?
So can you now fix the DATA step code to properly make use of macro variable &file_upload_date ??
ALWAYS
use this button for posting logs:
as otherwise the horizontal formatting will be destroyed, and lots of useful information for debugging is lost.
SYMBOLGEN: Macro variable FILE_UPLOAD_DATE resolves to 21MAY2020
See Maxim 28.
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;
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.