From: Patrick on
Avi
Your example doesn't create a macro var mmm with the value in
quotation marks...
Find below some examples. May be one of it will help you solve your
problem.
Patrick

data work.test;do i=1 to 2;output;end;run;
%macro numobs(dsn);
data _null_;
call symput('mmm1',left(put(nobs,8.)));
call symput('mmm2','"'||strip(put(nobs,8.))||'"');
call symput('mmm3','"'||put(nobs,z8.)||'"');
stop;
set &dsn nobs=nobs;
run;

%if &mmm1 < 2 %then
%put mmm1=&mmm1 ---> mmm1 < 2;
%else
%put mmm1=&mmm1 ---> mmm1 >= 2;

%if %sysfunc(compress(&mmm2,'"')) < 2 %then
%put mmm2=&mmm2 ---> mmm2 < 2;
%else
%put mmm2=&mmm2 ---> mmm2 >= 2;

%if &mmm3 < "00000002" %then
%put mmm3=&mmm3 ---> mmm3 < 2;
%else
%put mmm3=&mmm3 ---> mmm3 >= 2;

%mend numobs;
%numobs(dsn=work.test);
From: Ian Whitlock on
Avi,

1 %macro numobs(dsn);
2 %global mmm;
3 data _null_;
4 if 0 then set &dsn nobs=nobs;
5 call symput('mmm',trim(left(put(nobs,8.))));
6 stop;
7 run;
8 %mend numobs;
9
10 data w ; do obs = 1 to 3 ; output ; end ; run ;
11 %numobs(w) ;
12 %put %eval(&mmm<2) ;
0

So, whats the problem again?

See

http://listserv.uga.edu/cgi-bin/wa?A2=ind0712c&L=sas-l&O=A&P=3454

for a NOBS macro that does a much better job.

Ian Whitlock
==============

Date: Tue, 25 Dec 2007 14:16:52 -0800
Reply-To: avi <aviben(a)BEZEQINT.NET.IL>
Sender: "SAS(r) Discussion"
From: avi <aviben(a)BEZEQINT.NET.IL>
Organization: http://groups.google.com
Subject: Re: Macro variable comparison
Comments: To: sas-l
Content-Type: text/plain; charset=ISO-8859-1

The code is a macro that computes the number of observations in a
dataset

%macro numobs(dsn);
%global mmm;
data _null_;
if 0 then set &dsn nobs=nobs;
call symput('mmm',trim(left(put(nobs,8.))));
stop;
run;
%mend numobs;

Thanks Avi
From: "data _null_," on
Would the DEQUOTE function be helpful?

935 %let mmm = "3" ;
936 %put mmm = >>>&mmm<<< ;
mmm = >>>"3"<<<
937 %put %eval(&mmm<2) ;
1
938 /* assuming surrounding quote marks */
939 %put >>>%sysfunc(dequote(&mmm))<<< ;
>>>3<<<
940 %put %eval(%sysfunc(dequote(&mmm))<2) ;
0

941 %let mmm = '3' ;
942 %put mmm = >>>&mmm<<< ;
mmm = >>>'3'<<<
943 %put %eval(&mmm<2) ;
1
944 /* assuming surrounding quote marks */
945 %put >>>%sysfunc(dequote(&mmm))<<< ;
>>>3<<<
946 %put %eval(%sysfunc(dequote(&mmm))<2) ;
0


On Dec 25, 2007 4:40 PM, Ian Whitlock <iw1junk(a)comcast.net> wrote:
> Summary: Quote marks are for generated SAS code.
> #iw-value=1
>
> Avi,
>
> Simplest solution is to avoid quote marks in the first place.
>
> However, here are 3 solutions when you already have them.
>
> %let mmm = "3" ;
> %put mmm = >>>&mmm<<< ;
> %put %eval(&mmm<2) ;
>
> /* assuming single digit with surrounding quote marks */
> %put >>>%substr(&mmm,2,1)<<< ;
> %put %eval(%substr(&mmm,2,1)<2) ;
>
> /* assuming surrounding quote marks */
> %put >>>%sysfunc(translate(&mmm,%str( ),%str(%"%')))<<< ;
> %put %eval(%sysfunc(translate(&mmm,%str( ),%str(%"%')))<2) ;
>
> %let q = %qsubstr(&mmm,2) ;
> %let q = %substr(&q,1,%length(&q)-1) ;
> %put >>>&q<<< ;
> %put %eval(&q<2) ;
>
> Ian whitlock
> =================
> Date: Tue, 25 Dec 2007 13:35:20 -0800
> Reply-To: avi <aviben(a)BEZEQINT.NET.IL>
> Sender: "SAS(r) Discussion"
> From: avi <aviben(a)BEZEQINT.NET.IL>
> Organization: http://groups.google.com
> Subject: Macro variable comparison
> Comments: To: sas-l
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hello,
>
> I have a macro variable &mmm that resolves to "3" (not 3!)
>
> I want to make a comparison of the form:
>
> %eval(&mmm<2)
>
> I got TRUE mmm is interpreted as string
>
> How do I cause the comparison to interpret &mmm as 3 and not as "3"?
>
> Or, how do I cause &mmm to resolve to 3 (and not "3")?
>
>
> I have used the many dequoting functions but whithout success so far
>
> Thanks a lot Avi
>