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 (April 2006, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 6 Apr 2006 13:16:37 +0100
Reply-To:   Dirk Nachbar <Dirk.Nachbar@DWP.GSI.GOV.UK>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Dirk Nachbar <Dirk.Nachbar@DWP.GSI.GOV.UK>
Subject:   %eval again
Content-Type:   text/plain; charset="us-ascii"

all

i am trying to sample repeatedly until I have a pre-specified inequality in the sample. in the samplegini macro two macro variables are called which are then used for the decision to sample again. somehow the whole %eval stuff doesn't work and it's driving me nuts. ignore the gini macro for the time being.

Dirk

options mprint mlogic; %macro gini(data=,var=); data gini; set &data; where &var>=0; run;

proc sort data=gini; by &var; run;

data gini (keep= &var id cumpay); set gini; id=_n_; retain cumpay 0; cumpay+&var; run;

proc summary data=gini; var id cumpay; output out=max max=; run;

data _null_; set max; call symput('gdp',cumpay); call symput('people',id); run;

data gini; set gini; xk=cumpay/&gdp; yk=id/&people; xkk=xk-lag(xk); ykk=yk+lag(yk); gini=xkk*ykk; run;

proc summary data=gini; var gini; output out=g sum=; run;

data g; set g; gini=abs(1-gini); run; %mend;

%macro samplegini(n=1000,a=0,j=1,gini=,tol=0.01,max=100,seed=123); %let k=1; %if (&k<&max) %then %do; data out; do i=1 to &n; y=max(0,&a+&j*normal(&seed)); output; end; run;

%gini(data=out,var=y);

data g; set g; diff=&gini-gini; abs=abs(diff); call symput('diff',put(diff,best12.)); call symput('abs',put(abs,best12.)); %put &diff, &abs; run;

%if %eval(&abs>&tol) %then %do; %let j=%eval(&j+&diff); %let seed=%eval(&seed+1); %end; %else %do; %put the inequality has been reached, the coefficient is &j; %goto finish; %end;

%let k=%eval(&k+1); %end; %else %put no convergence, difference=&diff;

%finish: %mend; %samplegini(gini=0.3);

Dirk Nachbar Assistant Economist Pensim2 Department for Work and Pensions Level 4, The Adelphi 1-11 John Adam St WC2N 6HT London 020 796 28531 ********************************************************************** This document is strictly confidential and is intended only for use by the addressee. If you are not the intended recipient, any disclosure, copying, distribution or other action taken in reliance of the information contained in this e-mail is strictly prohibited. Any views expressed by the sender of this message are not necessarily those of the Department for Work and Pensions. If you have received this transmission in error, please use the reply function to tell us and then permanently delete what you have received. Please note: Incoming and outgoing e-mail messages are routinely monitored for compliance with our policy on the use of electronic communications. **********************************************************************

The original of this email was scanned for viruses by the Government Secure Intranet (GSi) virus scanning service supplied exclusively by Cable & Wireless in partnership with MessageLabs.

On leaving the GSi this email was certified virus-free


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