LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 7 Oct 2009 14:44:08 -0700
Reply-To:     Steve James <spj1@CDC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Steve James <spj1@CDC.GOV>
Organization: http://groups.google.com
Subject:      Re: Urgent - Unable to rectify the error
Comments: To: sas-l@uga.edu
Content-Type: text/plain; charset=ISO-8859-1

On Oct 7, 2:10 am, Zish <zishanpur...@gmail.com> wrote: > See the code below > > %macro test23; > data test2; > set in.test4; > %do i =1 %to 2; > put &i; > %if f_nn = &i %then %do; /* f_nn is a column having numerical values > */ > %put &i ; > %do j =2 %to 3; > %if C_nn = &j %then %do; /*C_nn is a column having numerical > values */ > %put &j; month_&j. = 1; > %end; > %end; > %end; > %end; > run; > %mend; > %test23; > > The log generated is > > MLOGIC(TEST23): Beginning execution. > MPRINT(TEST23): data test2; > MPRINT(TEST23): set in.test4; > MLOGIC(TEST23): %DO loop beginning; index variable I; start value is > 1; stop value is 2; by value > is 1. > SYMBOLGEN: Macro variable I resolves to 1 > NOTE: Line generated by the macro variable "I". > 1 1 > - > 22 > SYMBOLGEN: Macro variable I resolves to 1 > MLOGIC(TEST23): %IF condition f_nn = &i is FALSE > MLOGIC(TEST23): %DO loop index variable I is now 2; loop will > iterate again. > MPRINT(TEST23): put 1; > SYMBOLGEN: Macro variable I resolves to 2 > NOTE: Line generated by the macro variable "I". > 1 2 > - > 22 > SYMBOLGEN: Macro variable I resolves to 2 > MLOGIC(TEST23): %IF condition f_nn = &i is FALSE > MLOGIC(TEST23): %DO loop index variable I is now 3; loop will not > iterate again. > MPRINT(TEST23): put 2; > MPRINT(TEST23): run; > > ERROR 22-322: Syntax error, expecting one of the following: a name, #, > +, @. > > NOTE: The SAS System stopped processing this step because of errors. > WARNING: The data set WORK.TEST2 may be incomplete. When this step > was stopped there were 0 > observations and 14 variables. > WARNING: Data set WORK.TEST2 was not replaced because this step was > stopped. > NOTE: DATA statement used (Total process time): > real time 0.03 seconds > cpu time 0.00 seconds > > MLOGIC(TEST23): Ending execution. > > The problem is the If statement is coming out to be false, where as > there are values in the dataset which had the value for f_nn as > 1,2,3,4 etc. Please suggest the possible cause of error.

You're confusing macro code with data step code. The statement %if f_nn eq &i will never be true. The string 'f_nn' is not going to match a number. It looks like if you simply removed all of the %'s and &'s and removed the period after month_j the code may do what you're looking for.

Steve


Back to: Top of message | Previous page | Main SAS-L page