BookmarkSubscribeRSS Feed
R_A_G_
Calcite | Level 5
Hi,
I was wondering why my code does not work.

Thank you


DATA QMATRIX;
SET QMATRIX;
array itematt(3);
do i=1 to 3;
IF ITEM=1 THEN itematt&i=1;
END;
drop i;
run;

ERROR:


180: LINE and COLUMN cannot be determined.
NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL may allow recovery of the LINE and COLUMN where
the error has occurred.
ERROR 180-322: Statement is not valid or it is used out of proper order.
MPRINT(MISQMATRIX): data qmatrix;
MPRINT(MISQMATRIX): set qmatrix;
MPRINT(MISQMATRIX): IF ITEM=1 THEN itematt1-itematt3=1 ;
MPRINT(MISQMATRIX): Run;
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.QMATRIX may be incomplete. When this step was stopped there were 0
observations and 4 variables.
WARNING: Data set WORK.QMATRIX was not replaced because this step was stopped.
5 REPLIES 5
chang_y_chung_hotmail_com
Obsidian | Level 7
The log reports that your if statement resolves to:
> IF ITEM=1 THEN itematt1-itematt3=1 ;
which is incorrect.
R_A_G_
Calcite | Level 5
thanks, I changed the syntax to this and still it does not run.

%macro MISQMATRIX;
%let num_skills=3;

DATA Q_MATRIX_WR;
set QMatrix;
array skills(&num_skills);

do i=1 to &num_skills;
IF question=1 THEN skills1=1 skills2=1 skills3=1;
ELSE
skills(i)=1- skills(i);
END;
drop i;
run;
%mend;

ERROR:
NOTE 137-205: Line generated by the invoked macro "MISQMATRIX".
1 DATA Q_MATRIX_WR; set QMatrix; array skills(&num_skills); do i=1 to &num_skills; IF
1 ! question=1 THEN skills1=1 skills2=1 skills3=1; ELSE skills(i)=1- skills(i); END; drop i;
-------
22
1 ! run;
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, ;, <, <=,
<>, =, >, ><, >=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=,
|, ||, ~=.

MPRINT(MISQMATRIX): do i=1 to 3;
NOTE 137-205: Line generated by the invoked macro "MISQMATRIX".
1 DATA Q_MATRIX_WR; set QMatrix; array skills(&num_skills); do i=1 to &num_skills; IF
1 ! question=1 THEN skills1=1 skills2=1 skills3=1; ELSE skills(i)=1- skills(i); END; drop i;
-------
22
1 ! run;
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, ;, <, <=,
<>, =, >, ><, >=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=,
|, ||, ~=.

MPRINT(MISQMATRIX): IF question=1 THEN skills1=1 skills2=1 skills3=1 ;
MPRINT(MISQMATRIX): ELSE skills(i)=1- skills(i);
MPRINT(MISQMATRIX): END;
MPRINT(MISQMATRIX): drop i;
MPRINT(MISQMATRIX): run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.Q_MATRIX_WR may be incomplete. When this step was stopped there were
0 observations and 4 variables.
Doc_Duke
Rhodochrosite | Level 12
You are mixing up array syntax and macro syntax.

array itematt(3);
do i=1 to 3;
IF ITEM=1 THEN itematt&i=1;
END;
uses the macro variable "i" (undefined), as well as an incorrect type of "container" on the ARRAY statement itself.

Change the syntax
array itematt{3};
do i=1 to 3;
IF ITEM=1 THEN itematt{i}=1;
END;
Note the {...} "container".
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Curious how this post fits into the Statistical Procedures forum?

Suggest you get rid of the macro and get your standalone SAS DATA step working before making it more flexible with macro language elements. Substitute constants (or if absolutely necessary use static macro variables).

Scott Barry
SBBWorks, Inc.
R_A_G_
Calcite | Level 5
Thank you Doc, It is always great to read constructive comment vs. criticism of our lack of knowledge.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 4678 views
  • 0 likes
  • 4 in conversation