v8.2 macro question - passing the contents of a data step var iable to a macro

v8.2 macro question - passing the contents of a data step var iable to a macro

Post by Droogendyk, Har » Sat, 04 Aug 2001 21:59:47



Andreas:

No, no, I was the one with the half-baked solution.  I was merely pointing
out that I was attempting to solve a problem one way ( half-baked because it
didn't work, mixing macro and data step ) and Puddin' Man suggested an
entirely new solution that did work.

Please understand that I'm appreciative of each suggestion / solution
provided; each one is an opportunity to broaden my knowledge of SAS.

Regards,
Harry

-----Original Message-----

Sent:   August 3, 2001 4:40 AM

Subject:        Re: v8.2 macro question - passing the contents of a data

step variabl              e to a macro

Hey Harry,

I showed you and Puddin'Man in a private email that the following
statement is definitely not true
"Adding call symput( ) doesn't help since the symput'ed variable isn't
available until the data step completes.".

Then I asked you what do you want to achieve with your program because
you did not explain it. And you did not answer.

"Therein lies the real beauty of this list; the ability of folks to
interpret
the problem and suggest a real solution rather than the sometimes
half-baked
one that promoted the question in the first place."
If you would like to indicate that me is under the latter folks (the
half-baked ones) I really can't follow you.

Sincerely yours

 
 
 

1. v8.2 macro question - passing the contents of a data step variabl e to a macro

Listers:

In v8.2, is it possible to invoke a macro within a data step and pass to the
macro the contents of a data step variable defined within that datastep?
Note that the following silliness is for illustration only, the real macro
has some meat that requires it to be a macro.

e.g.
%global other;
%macro dumb_macro(stuff);
    %let other = %scan(&stuff,1,'/');
%mend;

data harry;
   input 'c:\test.txt';
   input var1 var2 var3;
   %dumb_macro(var1);  /* passes the literial 'var1' rather than contents of
var1 */
   var4 = "&other";
run;

Adding call symput( ) doesn't help since the symput'ed variable isn't
available until the data step completes.

Am I destined to do something like the following:

data harry;
   retain x 0;
   infile 'c:\blah.txt' end=eof;
   input var1 var2 var3;
   call symput('var'||trim(left(x)),var1);
   if eof then call symput('limit',x);
run;

%macro loop;
%local x;
data second;
 %do x = 1 %to &limit;
     %dumb_macro(&&var&x);
      var4 = "&other";
      output;
   %end;
run;
%mend loop;
%loop;

then merge datasets 'harry' and 'second'.

TIA

2. Question - on the XP browsing issue

3. v8.2 macro question - passing the contents of a data step

4. What causes these "="'s and "=20"'s???

5. v8.2 macro question - passing the contents of a data step var iabl e to a macro

6. Font Typographer list needed

7. How to assign a data step character value to a macro var

8. Transaction-oriented undo mechanism

9. Thanks - v8.2 macro question - passing the contents of a data ste p variabl e to a macro

10. macro help: reference %global macro vars

11. A question about macro invocation within data step

12. SYSPARM: MACRO v Data Step question

13. MSExcel button macro pass var how?