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 (January 2006, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 6 Jan 2006 21:43:50 -0800
Reply-To:   David L Cassell <davidlcassell@MSN.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   David L Cassell <davidlcassell@MSN.COM>
Subject:   Re: An example with the call symput routine
In-Reply-To:   <>
Content-Type:   text/plain; format=flowed

rune@FASTLANE.NO wrote: >I don't understand an error message I get from the log. > >*This code shows the content of the table COURSES. This is the table >SASUSER.COURSE, I guess it follows every version of SAS, I've just copied >it >to WORK. ; >proc sql; > select * > from courses; > quit; > /* > Course Course Course > Code Description Length Fee > ------------------------------------------------- > C001 Basic Telecommunications 3 $795 > C002 Structured Query Language 4 $1150 > C003 Local Area Networks 3 $650 > C004 Database Design 2 $375 > C005 Artificial Intelligence 2 $400 > C006 Computer Aided Design 5 $1600 > */ > >*And this code seems to cause the problem; > options symbolgen pagesize=30; > %let crsnum=C003; > data price; > set courses; > where course_code=&crsnum; /* <--OBS */ > call symput('daily_fee', put(fee/days,dollar8.)); > run; > /* > 160 data price; > 161 set courses; > 162 where course_code=&crsnum; > SYMBOLGEN: Macro variable CRSNUM resolves to C003 > ERROR: Variable C003 is not on file WORK.COURSES. > 163 call symput('daily_fee', put(fee/days,dollar8.)); > 164 run; > */ > >I can't see what's wrong with the code.

I think that if you run this after running the line:

options mprint;

your problem might be clearer. You see, the problem is NOT with the CALL SYMPUT statement. In fact, it is clear from the log that the error occurs before you get that far down. The problem is with your WHERE statement.

MPRINT should show you that you actually wrote:

where course_code=C003;

But this can't be a number. It can't be a string, since it is not enclosed in quotes. So C003 must get parsed as another variable. And that's your error message:

> ERROR: Variable C003 is not on file WORK.COURSES.

So all you have to do is put your macro variable in double quotes, so it will be recognized as a string.

BTW, if I were you I would try using PROC SQL to shove this into a macro variable using the INTO keyword. I think it's cleaner, and more flexible.

HTH, David -- David L. Cassell mathematical statistician Design Pathways 3115 NW Norwood Pl. Corvallis OR 97330

_________________________________________________________________ Donít just search. Find. Check out the new MSN Search!

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