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 (March 1997, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 28 Mar 1997 07:32:15 GMT
Reply-To:     David Michael Wright <david@CATS.UCSC.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         David Michael Wright <david@CATS.UCSC.EDU>
Organization: University of California, Santa Cruz
Subject:      Re: A BETTER SAS, part 1

In article <3332FD08.6D6B@sbphrd.com>, Steven_Hanks-1 <Steven_Hanks-1@sbphrd.com> wrote: |David Michael Wright wrote (And Steve Annotated) | |> SAS should elliminate all proceedures and replace them with functions. |> Then you wouldn't have the bizarre macro language that is nearly |> impossible to remember and learn, or a separte matrix language with |> it's convoluted syntax and limted functionality (not to mention |> expense) | |OK, I'll agree that macro language looks strange. But 'bizarre' and |'impossible to remember'?....

A simple tour through the days' post brings up couple of different answers on how to assign records to macros: - very simple to do in common languages with arrays:

On Tue, 25 Mar 1997 07:03:13 +0000, Roland <RolandRB@nospam.netcomuk.co.uk> wrote:

data _null_; set whatever; call execute('%top('||first||','||last||')'); run;

I tried something like this once, but got dizzy looking at the pipe and apostrophes and it did not work.

Scott Came, Sr Programmer/Analyst wrote:

data obs; input first last; cards; 1 3 4 4 5 6 7 9 ; run;

%macro top (first, last); %* a trivial TOP macro--yours will do real stuff in here. *; %put RUNNING TOP: first=&first last=&last; %mend top;

%macro doit;

options nonotes; %* optional--makes log look nicer *;

%local ptr nobs i first last;

%* read number of obs in dataset OBS into a macro var. *;

proc contents data=obs noprint out=conout(keep=nobs); run;

data _null_; set conout; call symput("nobs",compress(nobs)); stop; run;

%* loop thru the observations in OBS, feeding FIRST and LAST into TOP *;

%do i = 1 %to &nobs;

data _null_; set obs(firstobs=&i); call symput("first",compress(first)); call symput("last",compress(last)); stop; run;

%top(&first,&last)

%end;

%* clean up *;

proc datasets library=work nolist; delete nobs; run;

options notes; %* again, optional *;

%mend doit; %doit

I rest my case!


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