|
>13 %let wonder=%sysfunc(length(compress(&a)));
>14 %put value of Wonder &wonder;
>value of Wonder 12
>
>I got the value of a correctly i.e 29. Here I don't understand this.
Next I am trying to get the length of compressed(&a). I should get 2
here becaz the value >of a is 29 then the length of 29 should be 2.Is
not it?.
This is the same problem as the other one. 12 is the length of
"compress(29)". You need another %sysfunc in there.
>My one more equestion is why the follwong %cmpres does n't work.
>
>%let wondervar=123 4567;
>%let wonder1=%sysfunc(length(%cmpres(&wondervar)));
>%put value of wonder var1 &wonder1;
>
>24 %let wondervar=123 4567;
>25 %let wonder1=%sysfunc(length(%cmpres(&wondervar)));
>26 %put value of wonder var1 &wonder1;
>value of wonder var1 8
The length of "123 4567" is 8. %cmpres reduces multiple blanks to a
single blank, but doesn't eliminate all blanks. The data step function
COMPRESS does, but it's not the same as the macro function %CMPRES -
that's why they have different names.
>Here I am really confusing when should I use the macro functions and
when should I use the regular functions with %sysfunc. You know what I
mean.
The general rule I would follow is to use a macro function when an
appropriate one is available, and to use a data step function if that's
my only choice. It frequently will be, since there are many more data
step functions than macro functions.
--
JackHamilton@FirstHealth.com
Manager, Technical Development
Metrics Department, First Health
West Sacramento, California USA
>>> "Ramesh Makkena" <makkena@xoma.com> 03/20/2003 6:17 PM >>>
Hi Jack,
Thanks for your earliest response.
But here are some suggestions:
1) The value of wonder is unresolved in the statement
%put value of wonder var1 &wonder1;
because you never closed the comment starting with "* here", so
the %let statement wasn't executed.
* never mind I wrote the comment after I ran the program. It's ok. The
problem comes here.
%let nvar=variable1 variable2 variable3;
%let a=%length(&nvar);
%put value of a is &a;
%let wonder=%sysfunc(length(compress(&a)));
%put value of Wonder &wonder;
My log says :
7 %let nvar=variable1 variable2 variable3;
8
9 %let a=%length(&nvar);
10
11 %put value of a is &a;
value of a is 29
12
13 %let wonder=%sysfunc(length(compress(&a)));
14 %put value of Wonder &wonder;
value of Wonder 12
I got the value of a correctly i.e 29. Here I don't understand this.
Next I am trying to get the length of compressed(&a). I should get 2
here becaz the value of a is 29 then the length of 29 should be 2.Is not
it?.
2) The statement
%let aok_but_no_success=%sysfunc(length(compress(&nvar)));
returns the value 39 because that's the length of
"compress(variable1 variable2 variable3)".
The evaluation of text as a data step function applies to the
word
immediately after the open
parenthesis, and not to any nested functions. You probably want
%let
aok_but_no_success=%sysfunc(length(%sysfunc(compress(&nvar))));
which returns 27.
Yes. You are correct. If I add one more %sysfunc I will get the correct
value.
It got worked by adding %sysfunc before compress function:
%let wondervar=123 4567;
%let wonder1=%sysfunc(length(%sysfunc(compress(&wondervar))));
%put value of wonder var1 &wonder1;
my log :
20 %let wondervar=123 4567;
21 %let wonder1=%sysfunc(length(%sysfunc(compress(&wondervar))));
22 %put value of wonder var1 &wonder1;
value of wonder var1 7
My one more equestion is why the follwong %cmpres does n't work.
%let wondervar=123 4567;
%let wonder1=%sysfunc(length(%cmpres(&wondervar)));
%put value of wonder var1 &wonder1;
24 %let wondervar=123 4567;
25 %let wonder1=%sysfunc(length(%cmpres(&wondervar)));
26 %put value of wonder var1 &wonder1;
value of wonder var1 8
Here I am really confusing when should I use the macro functions and
when should I use the regular functions with %sysfunc. You know what I
mean.
Thanks,
Ramesh makkena
--
JackHamilton@FirstHealth.com
Manager, Technical Development
Metrics Department, First Health
West Sacramento, California USA
>>> "Ramesh Makkena" <makkena@XOMA.COM> 03/20/2003 3:50 PM >>>
Hi,
I am really trying to understand the macro functions and system
function calls in the macro variable assignment.
I am really trying to learn when can I use the macro functions and
when
can I use the functions through %sysfunc. I would appreciate if
anybody
can give me a brief view.
%let nvar=variable1 variable2 variable3;
* this is ok my little brain catch this;
%let a=%length(&nvar);
%put Length of NVAR &a;
* here my little brain breaks;
%let aok_but_no_success=%sysfunc(length(compress(&nvar)));
%put value of aok_but_no_success &aok_but_no_success;
* this one is also ok;
%let aok_success=%length(%sysfunc(compress(&nvar)));
%put value of &aok_success;
* there I go, why can't I just use the cmpres macro function to
compress the values;
%let comp_doubt=%cmpres(&nvar);
%put value of &comp_doubt;
* here I was wondering I am trying to get the length of the length,
you
guys might wonder why I am doing this. Nothing just for curious. I am
telling the truth I am developing a new S/W SASPHARMA :-). Just
kidding..
%let wonder=%sysfunc(length(compress(&a)));
%put value of Wonder &wonder;
%let wondervar=123 4567;
%let wonder1=%sysfunc(length(compress(&wondervar)));
%put value of wonder var1 &wonder1;
I would appreciate your time if anybody could give me a wonderful
explanation.
TIA,
Ramesh Makkena
|