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
deleted_user
Not applicable
Try removing % sign in if-else-then and do-end loop statments.

~ Sukanya E
deleted_user
Not applicable
> Try removing % sign in if-else-then and do-end loop
> statments.
>
> ~ Sukanya E

It worked perfectly and Thanks infinitely
I guess the issue i had initially was execution time versus interpretation time
wasn't ?
What do you think i should know about in order to avoid this kind of problems ?
thanks in advance
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Solid understanding of differences between SAS macro compilation and SAS DATA/PROC step execution. Also, my suggestion is to always code a RUN; to force SAS code interpretation.

A few handy SAS diagnostics commands to use (frequently):

OPTIONS SOURCE SOURCE2;

OPTIONS MACROGEN SYMBOLGEN MLOGIC;


And for DATA step processing, the judicious use of PUTLOG (new with SAS 9) to echo messages during execution, for example:

PUTLOG '>DIAG01' / _ALL_;


Scott Barry
SBBWorks, Inc.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 625 views
  • 0 likes
  • 2 in conversation