BookmarkSubscribeRSS Feed
raivester
Quartz | Level 8

I am reading in a set of data sets that share a naming convention, but each subsequent data set name has a suffix that is incremented by 1--i.e., tx1, tx2, . . . tx28. Three of the 28 data sets have a variable that is num, when in the rest of the data sets this variable is char. I am trying to make the type consistent before appending these data sets; however, I am getting a SPOOL error. 

 

%macro vartype;
	%do i=1 %to 28;
		data tx2&i;
		  set tx&i.; 
		  	CASE_CAUSE_NBR2 = trim(left(put(CASE_CAUSE_NBR, 9.);
		run;
	%end;
%mend vartype;
%vartype;

When I comment out the line that generates the new variable, the code runs successfully; however, when I include it, that's when the error arises . . . 

 

MLOGIC(VARTYPE): %DO loop index variable I is now 28; loop will iterate again.
SYMBOLGEN: Macro variable I resolves to 28
MPRINT(VARTYPE): data tx228;
SYMBOLGEN: Macro variable I resolves to 28
22: LINE and COLUMN cannot be determined.
NOTE 242-205: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN
where the error has occurred.
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, ), *, **, +, ',', -, /, <, <=,
<>, =, >, ><, >=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOT, NOTIN, OR, ^,
^=, |, ||, ~, ~=.
76: LINE and COLUMN cannot be determined.
NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where
the error has occurred.
ERROR 76-322: Syntax error, statement will be ignored.
MPRINT(VARTYPE): set tx28;
MPRINT(VARTYPE): CASE_CAUSE_NBR2 = trim(left(put(CASE_CAUSE_NBR, 9.);
MPRINT(VARTYPE): run;
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.TX228 may be incomplete. When this step was stopped there were 0
observations and 66 variables.
WARNING: Data set WORK.TX228 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

Any ideas?

2 REPLIES 2
SASKiwi
PROC Star

You are missing two right brackets:

CASE_CAUSE_NBR2 = trim(left(put(CASE_CAUSE_NBR, 9.)));
Kurt_Bremser
Super User

How were these datasets created in the first place? Depending on the source type, you can set the variable types consistently when the data is brought into SAS.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1008 views
  • 0 likes
  • 3 in conversation