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 (April 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Sat, 4 Apr 2009 12:38:20 +0200
Reply-To:   Rune Runnestø <rune@FASTLANE.NO>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Rune Runnestø <rune@FASTLANE.NO>
Subject:   A problem with macro logic
Comments:   To: sas-l@uga.edu

Here is the macro definition: ----------------------------- %macro print_ds( lib = , dsn = , topptekst = , botntekst = , overskrift = , abs_sti_utfil = , alle_postar = , ant_postar = 0 ); %numobs(&lib..&dsn); %put numobs = &numobs; %put Kommentar 1: alle_postar = %upcase(&alle_postar); %if %upcase(&alle_postar) = JA %then %do; %let ant_postar = &numobs; %put kommentar 2: ant_postar = &ant_postar; %end; %put ant_postar = &ant_postar; %mend;

And here is the call for the macro: ----------------------------------- %print_ds( lib = sasmeta, dsn = MacVar_dirnames_level_1, topptekst = nei, botntekst = nei, overskrift = Innhold i datasettet MacVar_dirnames_level_1, abs_sti_utfil = D:\SAS_KODE\Arkade_TestApp\MavVar_dirnames_level_1.doc, alle_postar = ja ant_postar = /* enten ' ' eller eit siffer. Blank viss 'alle_postar har verdi */ );

3012 %print_ds( lib = sasmeta, MLOGIC(PRINT_DS): Beginning execution. 3013 dsn = MacVar_dirnames_level_1, 3014 topptekst = nei, 3015 botntekst = nei, 3016 overskrift = Innhold i datasettet MacVar_dirnames_level_1, 3017 abs_sti_utfil = D:\SAS_KODE\Arkade_TestApp\MavVar_dirnames_level_1.doc, 3018 alle_postar = ja 3019 ant_postar = 3020 );

And here is the log message, with the most impont macro features turned on: --------------------------------------------------------------------------- MLOGIC(PRINT_DS): Parameter LIB has value sasmeta MLOGIC(PRINT_DS): Parameter DSN has value MacVar_dirnames_level_1 MLOGIC(PRINT_DS): Parameter TOPPTEKST has value nei MLOGIC(PRINT_DS): Parameter BOTNTEKST has value nei MLOGIC(PRINT_DS): Parameter OVERSKRIFT has value Innhold i datasettet MacVar_dirnames_level_1 MLOGIC(PRINT_DS): Parameter ABS_STI_UTFIL has value D:\SAS_KODE\Arkade_TestApp\MavVar_dirnames_level_1.doc MLOGIC(PRINT_DS): Parameter ALLE_POSTAR has value ja ant_postar = MLOGIC(PRINT_DS): Parameter ANT_POSTAR has value 0 MLOGIC(PRINT_DS.NUMOBS): Beginning execution. SYMBOLGEN: Macro variable LIB resolves to sasmeta SYMBOLGEN: Macro variable DSN resolves to MacVar_dirnames_level_1 MLOGIC(PRINT_DS.NUMOBS): Parameter DSN has value sasmeta.MacVar_dirnames_level_1 MPRINT(PRINT_DS.NUMOBS): data _null_; MPRINT(PRINT_DS.NUMOBS): call symput('numobs', left(put(dsnobs,5.))); MPRINT(PRINT_DS.NUMOBS): stop; SYMBOLGEN: Macro variable DSN resolves to sasmeta.MacVar_dirnames_level_1 MPRINT(PRINT_DS.NUMOBS): set sasmeta.MacVar_dirnames_level_1 nobs = dsnobs; MPRINT(PRINT_DS.NUMOBS): run;

NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds

MLOGIC(PRINT_DS.NUMOBS): Ending execution. MPRINT(PRINT_DS): ; MLOGIC(PRINT_DS): %PUT numobs = &numobs SYMBOLGEN: Macro variable NUMOBS resolves to 27 numobs = 27 MLOGIC(PRINT_DS): %PUT Kommentar 1: alle_postar = %upcase(&alle_postar) SYMBOLGEN: Macro variable ALLE_POSTAR resolves to ja ant_postar = Kommentar 1: alle_postar = JA ANT_POSTAR = SYMBOLGEN: Macro variable ALLE_POSTAR resolves to ja ant_postar = MLOGIC(PRINT_DS): %IF condition %upcase(&alle_postar) = JA is FALSE MLOGIC(PRINT_DS): %PUT ant_postar = &ant_postar SYMBOLGEN: Macro variable ANT_POSTAR resolves to 0 ant_postar = 0 MLOGIC(PRINT_DS): Ending execution.

What is the problem? -------------------- The log message says: MLOGIC(PRINT_DS): %IF condition %upcase(&alle_postar) = JA is FALSE

Which should have been resolved to TRUE if SAS had the slightest fantacy of what was going on into my mind :-).

I suspect this to have an easy explanation. But I have been dwelling upon it now for so long time that I have lost my patience. Can anyone see why SAS interpret the code as it does?

Rune


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