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 (August 2000, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 28 Aug 2000 15:21:10 GMT
Reply-To:   "John M. Wildenthal" <jmwildenthal@MY-DEJA.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "John M. Wildenthal" <jmwildenthal@MY-DEJA.COM>
Organization:   Deja.com - Before you buy.
Subject:   Re: Better ways to get the difference between two fields?

You didn't say what kind of difference you wanted, so you might need to edit the last datastep.

The call would be something like:

%diffsum(lib1.data3, lib1.data4, lib2.dataout, patient_id doctor_seen, bill time_spent rx_costs);

Note the SPACES, NOT COMMAS between variables in the different lists.

Here's the (untested) macro:

%MACRO diffsum(ds1, ds2, dsout, sortvars, varlist);

%LOCAL vnum i vname;

%LET vnum = 1;

%DO %WHILE(NOT %LENGTH(%SCAN(&varlist,&vnum)); %LET vnum = %EVAL(&vnum + 1); %END;

DATA garbage2; SET &ds2 (RENAME=( %DO i = 1 %TO &vnum; %LET vname = %SCAN(&varlist,&i); &vname.2 = &vname %END; ); RUN;

PROC SORT &ds1; BY &sortvars ; RUN;

PROC SORT garbage2; BY &sortvars ; RUN;

DATA &dsout; MERGE &ds1 garbage2; BY &sortvars;

%DO i = 1 %TO &vnum; %LET vname = %SCAN(&varlist,&i); &vname._diff = ABS(&vname - &vname.2); &vname._sum = &vname + &vname.2; %END; RUN;

%MEND;

Sent via Deja.com http://www.deja.com/ Before you buy.


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