BookmarkSubscribeRSS Feed
deleted_user
Not applicable
what is wrong with my following code? your help is really appreciated
%let mcy=9;
%macro read;
filename in " path\fictional_data.txt";
data read;
infile in end=eof lrecl=10;
input @1 i&mcy.IDO $CHAR2.
@3 i&mcy.IPSS $CHAR5.
@8 i&mcy.IPHP $CHAR3.
;
%if (i&mcy.IDO ne 'AL' and i&mcy.IDO ne 'AK' ) and (i&mcy.IPSS ne ' ')
and (i&mcy.IPHP ne " " and i&mcy.IPHP ne "000" ) %then i&mcy.IDO="FR";
%else
%do ;
i&mcy.IDO="XX";
%end;
run;
%mend read;
%read

this is the log error i am getting

NOTE: Line generated by the invoked macro "READ".
5 run;
---
22
MPRINT(READ): i9IDO="FR" run
MLOGIC(READ): Ending execution.
ERROR 22-322: Syntax error, expecting one of the following: !,
!!, &, *, **, +, -, /, <, <=, <>, =, >, ><, >=,
AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG,
NL, NOTIN, OR, ^=, |, ||, ~=.

************any help is appreciated!!!!!!!!!!!! Message was edited by: statmn
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
You do not need to post a given query in multiple forums.

Scott Barry
SBBWorks, Inc.
deleted_user
Not applicable
thanks for letting me know that Message was edited by: statmn
deleted_user
Not applicable
i&mcy.IDO, i&mcy.IPSS and i&mcy.IPHP, are dataset variable not macro variable.
Use "If", instead of "%If" , "then" instead of "%then", "do" instead of "%do" and "end" instead of "%end"

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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