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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star
That's a result of using INTO within SQL. Eliminate the extra blanks by adding:

%let max_size = &max_size;

before trying to use the macro variable

View solution in original post

3 REPLIES 3
Astounding
PROC Star
That's a result of using INTO within SQL. Eliminate the extra blanks by adding:

%let max_size = &max_size;

before trying to use the macro variable
Samiresh
Calcite | Level 5

Thank you, the solution worked

Jagadishkatam
Amethyst | Level 16

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;
Thanks,
Jag

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 380 views
  • 0 likes
  • 3 in conversation