When ever i call upon the array reference it creates trailing or leading spaces which causes the program to fail. Please observe the below code where in the array reference i insert the size of the dataset and i call it to use in naming convention
i used such naming convention before and it never failed. is it some settings i should turn on or i am missing any syntax
table - trigger file
Name | Date | place |
Rock | 5 | RI |
Bye | 3 | NY |
Max | 2 | ST |
Your | 1 | PC |
code
data trigger_file_s1;
set trigger_file;
row_num = _n_;
run;
proc sql noprint;
select max(row_num) into :max_size
from trigger_file_s1;
quit;
data tablename_&max_size.
set trigger_file_s1;
run;
Error log:
MPRINT(DATAINGESTION): data trigger_file_s1;
MPRINT(DATAINGESTION): set trigger_file;
MPRINT(DATAINGESTION): row_num = _n_;
MPRINT(DATAINGESTION): run;
NOTE: There were 6 observations read from the data set WORK.TRIGGER_FILE.
NOTE: The data set WORK.TRIGGER_FILE_S1 has 6 observations and 3 variables.
NOTE: Compressing data set WORK.TRIGGER_FILE_S1 increased size by 100.00 percent.
Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
MPRINT(DATAINGESTION): proc sql noprint;
MPRINT(DATAINGESTION): select max(row_num) into :max_size from trigger_file_s1;
MPRINT(DATAINGESTION): quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
10 The SAS System 16:06 Wednesday, June 5, 2019
SYMBOLGEN: Macro variable MAX_SIZE resolves to 6
NOTE: Line generated by the invoked macro "DATAINGESTION".
1194 record_count ; run; data trigger_file_s1; set trigger_file; row_num = _n_; run; proc sql noprint;
1194 ! select max(row_num) into :max_size from trigger_file_s1; quit; data tablename_&max_size. set trigger_file_s1; run
___
56
1194 ! ;
ERROR 56-185: SET is not allowed in the DATA statement when option DATASTMTCHK=COREKEYWORDS. Check for a missing semicolon in the
DATA statement, or use DATASTMTCHK=NONE.
NOTE: Line generated by the macro variable "MAX_SIZE".
1194 tablename_ 6
_
22
200
MPRINT(DATAINGESTION): data tablename_ 6 set trigger_file_s1;
MPRINT(DATAINGESTION): run;
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;, _DATA_, _LAST_, _NULL_.
ERROR 200-322: The symbol is not recognized and will be ignored.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
Thank you, the solution worked
Issue is with the misisng semicolon after tablename_&max_size.
keep the semicolon and it should work.
data trigger_file_s1;
set trigger_file;
row_num = _n_;
run;
proc sql noprint;
select max(row_num) into :max_size
from trigger_file_s1;
quit;
data tablename_&max_size.;
set trigger_file_s1;
run;
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.